53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
import sys
|
|
import argparse
|
|
from lib.proxer_utils import get_mp4_url, download_mp4, get_embed_url
|
|
|
|
def download_video(url, filename, auth_token, output_dir):
|
|
"""
|
|
Downloads a video from Proxer and saves it to the specified directory.
|
|
|
|
:param url: The URL of the Proxer video page
|
|
:param filename: The desired filename for the downloaded video
|
|
:param auth_token: A tuple containing (cookie_name, cookie_value) for Proxer authentication
|
|
:param output_dir: Directory to save the downloaded video
|
|
"""
|
|
try:
|
|
print(f"Fetching embed URL for video: {url}...")
|
|
embed_url = get_embed_url(url, auth_token)
|
|
print(f"Embed URL fetched: {embed_url}")
|
|
|
|
print(f"Fetching MP4 URL for video: {url}...")
|
|
mp4_url = get_mp4_url(embed_url)
|
|
print(f"MP4 URL fetched: {mp4_url}")
|
|
|
|
# Prepare the output file path
|
|
output_file = f"{output_dir}/{filename}.mp4"
|
|
|
|
# Download the video
|
|
print(f"Downloading video {filename}...")
|
|
download_mp4(mp4_url, output_file, label=f"Downloading {filename}")
|
|
print(f"Video {filename} downloaded successfully!")
|
|
|
|
except Exception as e:
|
|
print(f"Error downloading video: {e}")
|
|
|
|
def parse_args():
|
|
"""Parse command-line arguments"""
|
|
parser = argparse.ArgumentParser(description="Download a video from Proxer.me")
|
|
parser.add_argument('-u', '--url', required=True, type=str, help="URL of the Proxer video page")
|
|
parser.add_argument('-f', '--filename', required=True, type=str, help="Filename for the downloaded video (without extension)")
|
|
parser.add_argument('-t', '--token', required=True, type=str, help="Proxer authentication token (cookie)")
|
|
parser.add_argument('-o', '--output', required=True, type=str, help="Directory to save the downloaded video")
|
|
|
|
return parser.parse_args()
|
|
|
|
if __name__ == "__main__":
|
|
# Parse command-line arguments
|
|
args = parse_args()
|
|
|
|
# Assuming the Proxer authentication token comes as a cookie string (name=value)
|
|
auth_token = tuple(args.token.split("="))
|
|
|
|
# Call the function to download the video
|
|
download_video(args.url, args.filename, auth_token, args.output)
|