Skip to content

Instantly share code, notes, and snippets.

@ArmoredCavalry
Created May 28, 2023 18:30
Show Gist options
  • Save ArmoredCavalry/a902df9b44d34963e1890a4038773b63 to your computer and use it in GitHub Desktop.
Save ArmoredCavalry/a902df9b44d34963e1890a4038773b63 to your computer and use it in GitHub Desktop.
Apple Aerial Video Downloader
import json
import urllib.request
import ssl
import os
from urllib.parse import urlparse
json_url = "https://raw.githubusercontent.com/theothernt/AerialViews/master/app/src/main/res/raw/tvos15.json" # From https://github.com/theothernt/AerialViews
save_directory = "../" # Replace with your directory
max_to_process = 250 # Replace with your maximum number
ignore_cert_errors = True # Ignore any SSL errors on video url
ctx = ssl.create_default_context()
# Ignore SSL certificate errors (sometimes occurs on Apple CDN)
if ignore_cert_errors:
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
# Fetch JSON data from URL
with urllib.request.urlopen(json_url) as url:
data = json.loads(url.read().decode())
videos = data['assets']
total_videos = min(len(videos), max_to_process)
processed_count = 0
# Download the videos
for video in videos:
if processed_count >= max_to_process:
break
urls = ["url-4K-HDR", "url-4K-SDR"]
for urlKey in urls:
if urlKey in video:
url = video[urlKey]
a = urlparse(url)
filename = os.path.basename(a.path)
save_path = os.path.join(save_directory, filename)
if os.path.isfile(save_path):
print(f"Skipping existing file {processed_count + 1} of {total_videos} - {filename}...")
else:
print(f"Downloading file {processed_count + 1} of {total_videos} - {filename}...")
with urllib.request.urlopen(url, context=ctx) as response, open(save_path, 'wb') as out_file:
data = response.read() # a `bytes` object
out_file.write(data)
processed_count += 1
break
input("Downloading Completed, Press Enter to exit...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment