youtube-dl/youtube_dl/extractor/googlephotos.py

65 lines
3.3 KiB
Python
Raw Normal View History

2023-02-22 02:08:36 +09:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
class GooglePhotosIE(InfoExtractor):
_VALID_URL = r'https?://photos\.google\.com/share/(.+?)/photo/(.+?)key=(?P<id>.*)'
_TEST = {
2023-02-23 02:37:49 +09:00
'url': 'https://photos.google.com/share/AF1QipO4IcvSjf_niq1icqPYPBK50FAsKWniuyVY7Mx8sMIDKZGb71hkUi6ZK9hgIFX-mQ/photo/AF1QipNewPmRaMZquiCgyNtz4McqeLBdkXLugNB3ov6_?key=RUhSeEVVajdhcTVic3o2Wk1URWlVZEtRdnRoaTl3',
2023-02-22 02:08:36 +09:00
'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)',
'info_dict': {
2023-02-23 02:37:49 +09:00
'id': 'AF1QipNewPmRaMZquiCgyNtz4McqeLBdkXLugNB3ov6_',
2023-02-22 02:08:36 +09:00
'ext': 'mp4',
'title': 'GooglePhotosVideo',
}
}
_formats = {
'133': {'ext': 'mp4', 'height': 240, 'format_note': 'DASH video', 'vcodec': 'h264'},
'134': {'ext': 'mp4', 'height': 360, 'format_note': 'DASH video', 'vcodec': 'h264'},
'135': {'ext': 'mp4', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'h264'},
'136': {'ext': 'mp4', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'h264'},
'137': {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'h264'},
'138': {'ext': 'mp4', 'format_note': 'DASH video', 'vcodec': 'h264'},
'160': {'ext': 'mp4', 'height': 144, 'format_note': 'DASH video', 'vcodec': 'h264'},
'212': {'ext': 'mp4', 'height': 480, 'format_note': 'DASH video', 'vcodec': 'h264'},
'264': {'ext': 'mp4', 'height': 1440, 'format_note': 'DASH video', 'vcodec': 'h264'},
'298': {'ext': 'mp4', 'height': 720, 'format_note': 'DASH video', 'vcodec': 'h264', 'fps': 60},
'299': {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'h264', 'fps': 60},
'266': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'vcodec': 'h264'},
'139': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'abr': 48, 'container': 'm4a_dash'},
'140': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'abr': 128, 'container': 'm4a_dash'},
'141': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'abr': 256, 'container': 'm4a_dash'},
'256': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'container': 'm4a_dash'},
'258': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'container': 'm4a_dash'},
'325': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'dtse', 'container': 'm4a_dash'},
'328': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'ec-3', 'container': 'm4a_dash'},
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
dash_formats = {}
formats = []
dash_mpd_fatal = True
dash_link = self._search_regex(r'''data-url\s*=\s*('|")(?P<link>(?:(?!\1).)+)''', webpage, group='link')
2023-02-22 02:08:36 +09:00
mpd_url = self._download_webpage(dash_link + '=mm,dash?alr=true', video_id)
for df in self._extract_mpd_formats(
mpd_url, video_id, fatal=dash_mpd_fatal,
formats_dict=self._formats):
dash_formats.setdefault(df['format_id'], df)
2023-02-22 02:08:36 +09:00
self._sort_formats(formats)
return {
'id': video_id,
'title': 'GooglePhotosVideo',
'formats': formats,
}