-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.json location changed(?) #24
Comments
Yes its gone https://appleinsider.com/articles/23/08/31/apple-abandons-itunes-movie-trailers-site-and-ios-app |
Well, RIP. I've not found an alternative solution as of yet, but I'm sure with time something will surface. Also just want to take this moment to thank Adam for the creation of the script! Countless hours have been spent with favorite trailers, with great quality, on repeat, so your work has been very much appreciated. |
Yes, it does seem that the Apple Trailers site is gone, and there are so few trailers on the Apple TV site that it's useless. Presumably it only has trailers for movies that are currently or will soon be available on Apple TV+. I'll see if I can find another source for high-quality trailers and if I can update the script to use it. Since it will no longer be Apple Trailers I'll probably create a new repository, if I get something working, but I'll update this repository with a link to it. |
Bummer. Thank you @aag for the solid tool. |
Ok. I had some free time to look at this and getting the list of movies from the browser Dev Tools is fairly easy: Visit Open up the Dev Tools Elements and find the list within a Array.from(Object.entries(JSON.parse(document.querySelector('#shoebox-uts-api-cache').textContent)))[0][1].canvas.shelves.reduce((agg, obj) => agg.concat(obj.items), []) Sample movie object{
"genres": [
{
"id": "umc.gnr.mov.thriller",
"name": "Thriller",
"type": "Genre",
"url": "https://tv.apple.com/us/genre/thriller/umc.gnr.mov.thriller"
}
],
"id": "umc.cmc.2f5ymu2pjl4ltgii2r28388r9",
"images": {
"shelfImage": {
"height": 2160,
"isP3": false,
"joeColor": "b:rgb(2,21,33) p:rgb(243,239,250) s:rgb(226,105,133) t:rgb(195,195,206) q:rgb(181,88,113)",
"supportsLayeredImage": false,
"url": "https://is5-ssl.mzstatic.com/image/thumb/Video126/v4/ef/50/c6/ef50c673-ca2a-d224-a261-8c9ba7746fd3/d3e8957f-d67d-49c6-91e0-a199ed0cd99a_TheGoodMother_iTunes_CoverArt_3840x2160.png/{w}x{h}.{f}",
"width": 3840
},
"shelfImageBackground": {
"height": 1080,
"isP3": false,
"joeColor": "b:rgb(75,65,57) p:rgb(246,228,192) s:rgb(248,214,143) t:rgb(212,196,165) q:rgb(213,184,126)",
"supportsLayeredImage": false,
"url": "https://is2-ssl.mzstatic.com/image/thumb/-bEtQPQ1bohtws62tqtzHA/{w}x{h}.{f}",
"width": 1920
},
"transitionImage": {
"height": 3240,
"isP3": false,
"joeColor": "b:rgb(0,3,12) p:rgb(15,189,243) s:rgb(3,161,232) t:rgb(12,151,197) q:rgb(2,129,188)",
"supportsLayeredImage": false,
"url": "https://is1-ssl.mzstatic.com/image/thumb/Features126/v4/9e/a3/7e/9ea37eee-c34b-4af9-0543-70160c76d3af/mzl.iclkwqpq.png/{w}x{h}sr.{f}",
"width": 4320
}
},
"releaseDate": 1693526400000,
"secondaryActions": [
"AddToUpNext"
],
"title": "The Good Mother",
"type": "Movie",
"url": "https://tv.apple.com/us/movie/the-good-mother/umc.cmc.2f5ymu2pjl4ltgii2r28388r9"
} After that - one can get the title and url from the movie object, then load each url to get the movie page, from which you can get the trailer video from the Although very fragile based on the above - this is what I came up with: #!/usr/bin/env python3
import os
import glob
import json
# import time
import requests
from bs4 import BeautifulSoup
from yt_dlp import YoutubeDL
from pathvalidate import sanitize_filename
req = requests.get('https://trailers.apple.com')
soup = BeautifulSoup(req.content, 'html.parser')
data = json.loads(soup.find(id='shoebox-uts-api-cache').text)
shelves = data[list(data.keys())[0]]['canvas']['shelves']
movies = [item for obj in shelves for item in obj['items']]
yt_opts = {
'format': 'bestvideo[ext=mp4]+bestaudio',
'outtmpl': '__trailer__.mp4',
'quiet': True,
'progress': True,
}
for movie in movies:
print(' --- Downloading: {}'.format(movie['title']))
# if movie['releaseDate']:
# release_date = time.strftime('%Y-%m-%d', time.gmtime(movie['releaseDate']/1000))
# filename = sanitize_filename(f"{movie['title']}.{release_date}-trailer.mp4")
# else:
# filename = sanitize_filename(f"{movie['title']}-trailer.mp4")
filename = sanitize_filename(f"{movie['title']}-trailer.mp4")
if os.path.isfile(filename):
print(' --- Skipped - file exists')
continue
req = requests.get(movie['url'])
soup = BeautifulSoup(req.content, 'html.parser')
trailer_url = soup.find(property="og:video").attrs['content']
# for a custom logger look at - https://github.com/yt-dlp/yt-dlp#adding-logger-and-progress-hook
with YoutubeDL(yt_opts) as ydl:
result = ydl.download([trailer_url])
if result == 0:
found = glob.glob('./__trailer__.*')
if len(found):
os.rename(found[0], filename)
print(' --- Ok - {}'.format(filename))
else:
print(' --- Error - download not found')
else:
print(' --- Error - download failed')
beautifulsoup4==4.12.2
pathvalidate==3.1.0
requests==2.31.0
yt-dlp==2023.7.6 Of course - this is super-simplified version of your script. It doesn't track what was downloaded, apart from file matching, and it doesn't put the files in a target directory. Nor has options for the video resolution. Although there are many options from the playlist file:
Edit: Changed to |
Hey, hi, @aag, hope life's treatin' you well! Almost a year has passed since the unfortunate phasing out of Apple Trailers, have you found another source for high quality trailers you might be able to share? YouTube's video bit rate really isn't getting it done for when I wish to grab a trailer or two once in a blue moon, and I bet I'm not the only one. Thanks! |
if anyone passes by and wants to contribute to this rusty ChatGPT-made project, don't hesitate... |
Looks like as of today the location for the .json has changed, as has the whole trailers page on apple.com, seems they are making it more Apple TV-facing and making back end changes while doing so -- getting "Error: could not load data from http://trailers.apple.com/trailers/home/feeds/just_added.json"
The text was updated successfully, but these errors were encountered: