1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-11-30 16:52:57 +01:00

[vimeo/generic] Move detection logic from GenericIE to VimeoIE

This commit is contained in:
Yen Chi Hsuan 2015-06-21 18:23:58 +08:00
parent 6a745c2c0f
commit b407e173e4
2 changed files with 20 additions and 12 deletions

View File

@ -43,6 +43,7 @@ from .senateisvp import SenateISVPIE
from .bliptv import BlipTVIE from .bliptv import BlipTVIE
from .svt import SVTIE from .svt import SVTIE
from .pornhub import PornHubIE from .pornhub import PornHubIE
from .vimeo import VimeoIE
class GenericIE(InfoExtractor): class GenericIE(InfoExtractor):
@ -1089,18 +1090,9 @@ class GenericIE(InfoExtractor):
if matches: if matches:
return _playlist_from_matches(matches, ie='RtlNl') return _playlist_from_matches(matches, ie='RtlNl')
# Look for embedded (iframe) Vimeo player vimeo_url = VimeoIE._extract_vimeo_url(url, webpage)
mobj = re.search( if vimeo_url is not None:
r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1', webpage) return self.url_result(vimeo_url)
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))
# Look for embedded YouTube player # Look for embedded YouTube player
matches = re.findall(r'''(?x) matches = re.findall(r'''(?x)

View File

@ -22,6 +22,7 @@ from ..utils import (
unified_strdate, unified_strdate,
unsmuggle_url, unsmuggle_url,
urlencode_postdata, urlencode_postdata,
unescapeHTML,
) )
@ -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): def _verify_video_password(self, url, video_id, webpage):
password = self._downloader.params.get('videopassword', None) password = self._downloader.params.get('videopassword', None)
if password is None: if password is None: