[5min] Remove helper method and modernize

Previously, other extractor would go call a private(!) helper method. Instead, just hardcode the 5min:video_id format - it's not if that would ever change.
This commit is contained in:
Philipp Hagemeister 2014-12-13 11:02:24 +01:00
parent 293f0f39ce
commit 5e1912cfc1
3 changed files with 32 additions and 40 deletions

View File

@ -3,7 +3,6 @@ from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from .fivemin import FiveMinIE
class AolIE(InfoExtractor): class AolIE(InfoExtractor):
@ -42,9 +41,10 @@ class AolIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id') video_id = mobj.group('id')
playlist_id = mobj.group('playlist_id') playlist_id = mobj.group('playlist_id')
if playlist_id and not self._downloader.params.get('noplaylist'): if not playlist_id or self._downloader.params.get('noplaylist'):
return self.url_result('5min:%s' % video_id)
self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (playlist_id, video_id)) self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (playlist_id, video_id))
webpage = self._download_webpage(url, playlist_id) webpage = self._download_webpage(url, playlist_id)
@ -69,4 +69,3 @@ class AolIE(InfoExtractor):
'entries': entries, 'entries': entries,
} }
return FiveMinIE._build_result(video_id)

View File

@ -3,7 +3,6 @@ from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from .fivemin import FiveMinIE
from ..utils import ( from ..utils import (
url_basename, url_basename,
) )
@ -27,11 +26,10 @@ class EngadgetIE(InfoExtractor):
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
if video_id is not None: if video_id is not None:
return FiveMinIE._build_result(video_id) return self.url_result('5min:%s' % video_id)
else: else:
title = url_basename(url) title = url_basename(url)
webpage = self._download_webpage(url, title) webpage = self._download_webpage(url, title)
@ -39,5 +37,5 @@ class EngadgetIE(InfoExtractor):
return { return {
'_type': 'playlist', '_type': 'playlist',
'title': title, 'title': title,
'entries': [FiveMinIE._build_result(id) for id in ids] 'entries': [self.url_result('5min:%s' % vid) for vid in ids]
} }

View File

@ -1,11 +1,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..compat import (
compat_str, compat_str,
compat_urllib_parse, compat_urllib_parse,
)
from ..utils import (
ExtractorError, ExtractorError,
) )
@ -13,7 +13,7 @@ from ..utils import (
class FiveMinIE(InfoExtractor): class FiveMinIE(InfoExtractor):
IE_NAME = '5min' IE_NAME = '5min'
_VALID_URL = r'''(?x) _VALID_URL = r'''(?x)
(?:https?://[^/]*?5min\.com/Scripts/PlayerSeed\.js\?(.*?&)?playList=| (?:https?://[^/]*?5min\.com/Scripts/PlayerSeed\.js\?(?:.*?&)?playList=|
5min:) 5min:)
(?P<id>\d+) (?P<id>\d+)
''' '''
@ -41,13 +41,8 @@ class FiveMinIE(InfoExtractor):
}, },
] ]
@classmethod
def _build_result(cls, video_id):
return cls.url_result('5min:%s' % video_id, cls.ie_key())
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
embed_url = 'https://embed.5min.com/playerseed/?playList=%s' % video_id embed_url = 'https://embed.5min.com/playerseed/?playList=%s' % video_id
embed_page = self._download_webpage(embed_url, video_id, embed_page = self._download_webpage(embed_url, video_id,
'Downloading embed page') 'Downloading embed page')