Last active
July 2, 2024 08:13
-
-
Save chadgroom/cb8e23bc7df199a945e278694953751a to your computer and use it in GitHub Desktop.
Connatix Video Player Downloader [https://www.connatix.com/] - Made a quick downloader for a personal task and decided to upload it as some others may find it useful, enjoy!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from seleniumwire import webdriver | |
import requests | |
from os import path, getcwd, startfile, name | |
from time import sleep | |
# from sys import argv | |
# CHAD GROOM - 2020 | |
# **INTENDED FOR LEGAL PURPOSES** | |
# **I AM NOT AFFILIATED WITH CONNATIX IN ANY WAY** | |
# Info about the player itself: https://www.connatix.com | |
# List of sites who use the player: https://trends.builtwith.com/websitelist/Connatix | |
URL = "https://www.funker530.com/video/c-ram-shooting-down-rockets-during-embassy-attack-today/" | |
# CREATE OUR OBJECT | |
class downloader(object): | |
# INITIALIZE OUR OBJECT | |
def __init__(self, url): | |
self.file = None | |
self.url = url | |
self.browser = webdriver.Firefox() | |
# DOWNLOADER::SEACH FOR / DOWNLOAD OUR VIDEO | |
def download(self): | |
self.browser.get(self.url) | |
while True: | |
# POLLING; WAITING FOR OUR PLAY BUTTON TO RENDER | |
buttons = self.browser.find_elements_by_class_name("cnx-play-icon") | |
if len(buttons) > 0: | |
break | |
# CLICK ALL THE PLAY BUTTONS UNTIL ONE WORKS LOL | |
for button in buttons: | |
try: | |
button.click() | |
break | |
except: | |
pass | |
# LET VIDEO BUFFER, LONGER VIDEOS/SLOWER SYSTEMS MAY TAKE LONGER. | |
sleep(5) | |
# FIND OUR MP4 IN OUR SESSION REQUESTS | |
file_ = None | |
for request in self.browser.requests: | |
if request.response: | |
if "0.mp4" in request.url: | |
file_ = request.url | |
break | |
# DOWNLOAD OUR VIDEO | |
if file_ is not None: | |
# PROPER FILE DELIMITER PER PLATFORM | |
if "nt" in name: | |
file_delimiter = "\\" | |
else: | |
file_delimiter = "/" | |
# DOWNLOAD OUR FILE | |
try: | |
r = requests.get(file_, allow_redirects=True) | |
open(path.basename(file_), 'wb').write(r.content) | |
self.file = getcwd() + file_delimiter + path.basename(file_) | |
return self.file | |
except: | |
loca = file_.replace(file_delimiter + path.basename(file_), "") | |
print(f"[FAILED] Failed to reach the file @ {loca}") | |
exit(1) | |
return None | |
# DOWNLOADER::PLAY OUR VIDEO | |
def open_video(self): | |
startfile(self.file) | |
# THE REASON I MADE THIS AN OBJECT WAS TO ASSIST OTHERS WITH FURTHER MODIFICATIONS. | |
if __name__ == "__main__": | |
#obj = downloader(argv[1]) | |
obj = downloader(URL) | |
print(obj.download()) # <- RETURNS FILENAME OR NONE, DEPENDING ON SUCCESS. | |
obj.open_video() | |
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selenium-wire==2.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you end up finding out the answer?