Skip to content

Commit

Permalink
[vimeo/generic] Move detection logic from GenericIE to VimeoIE
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Chi Hsuan committed Jun 21, 2015
1 parent 6a745c2 commit b407e17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 4 additions & 12 deletions youtube_dl/extractor/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from .bliptv import BlipTVIE
from .svt import SVTIE
from .pornhub import PornHubIE
from .vimeo import VimeoIE


class GenericIE(InfoExtractor):
Expand Down Expand Up @@ -1089,18 +1090,9 @@ def _playlist_from_matches(matches, getter=None, ie=None):
if matches:
return _playlist_from_matches(matches, ie='RtlNl')

# Look for embedded (iframe) Vimeo player
mobj = re.search(
r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1', webpage)
if mobj:
player_url = unescapeHTML(mobj.group('url'))
surl = smuggle_url(player_url, {'Referer': url})
return self.url_result(surl)
# Look for embedded (swf embed) Vimeo player
mobj = re.search(
r'<embed[^>]+?src="((?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)"', webpage)
if mobj:
return self.url_result(mobj.group(1))
vimeo_url = VimeoIE._extract_vimeo_url(url, webpage)
if vimeo_url is not None:
return self.url_result(vimeo_url)

# Look for embedded YouTube player
matches = re.findall(r'''(?x)
Expand Down
16 changes: 16 additions & 0 deletions youtube_dl/extractor/vimeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
unified_strdate,
unsmuggle_url,
urlencode_postdata,
unescapeHTML,
)


Expand Down Expand Up @@ -173,6 +174,21 @@ class VimeoIE(VimeoBaseInfoExtractor):
},
]

@staticmethod
def _extract_vimeo_url(url, webpage):
# Look for embedded (iframe) Vimeo player
mobj = re.search(
r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1', webpage)
if mobj:
player_url = unescapeHTML(mobj.group('url'))
surl = smuggle_url(player_url, {'Referer': url})
return surl
# Look for embedded (swf embed) Vimeo player
mobj = re.search(
r'<embed[^>]+?src="((?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)"', webpage)
if mobj:
return mobj.group(1)

def _verify_video_password(self, url, video_id, webpage):
password = self._downloader.params.get('videopassword', None)
if password is None:
Expand Down

0 comments on commit b407e17

Please sign in to comment.