Skip to content
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

Add GooglePhotosIE from tokune/youtube-dl #31640

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@
from .godtube import GodTubeIE
from .golem import GolemIE
from .googledrive import GoogleDriveIE
from .googlephotos import GooglePhotosIE
from .googlepodcasts import (
GooglePodcastsIE,
GooglePodcastsFeedIE,
Expand Down
43 changes: 43 additions & 0 deletions youtube_dl/extractor/googlephotos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor


class GooglePhotosIE(InfoExtractor):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be merged with GoogleDriveIE in youtube_dl/extractor/googledrive.py? There seems to be a lot of commonality.

_VALID_URL = r'https?://photos\.google\.com/share/(.+?)/photo/(.+?)key=(?P<id>.*)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the key not [\da-zA-Z]+ rather than .*? Maybe - is allowed, so [\da-zA-Z-]+ if so.

_TEST = {
'url': 'https://photos.google.com/share/AF1QipO4IcvSjf_niq1icqPYPBK50FAsKWniuyVY7Mx8sMIDKZGb71hkUi6ZK9hgIFX-mQ/photo/AF1QipNewPmRaMZquiCgyNtz4McqeLBdkXLugNB3ov6_?key=RUhSeEVVajdhcTVic3o2Wk1URWlVZEtRdnRoaTl3',
'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)',
'info_dict': {
'id': 'AF1QipNewPmRaMZquiCgyNtz4McqeLBdkXLugNB3ov6_',
'ext': 'mp4',
'title': 'GooglePhotosVideo',
}
}

_formats = YoutubeIE._formats

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')
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)


self._sort_formats(formats)

return {
'id': video_id,
'title': 'GooglePhotosVideo',
'formats': formats,
}