1
0
Fork 0
mirror of https://gitlab.com/dstftw/youtube-dl.git synced 2020-11-16 09:42:26 +00:00

BrightcoveIE: Use parse_qs to extract the fields of the query (closes #1032)

Add a compat_urlparse to utils.
This commit is contained in:
Jaime Marquínez Ferrándiz 2013-07-12 14:53:28 +02:00
parent 232eb88bfe
commit 6543f0dca5
2 changed files with 13 additions and 7 deletions

View file

@ -6,6 +6,7 @@ from .common import InfoExtractor
from ..utils import ( from ..utils import (
compat_urllib_parse, compat_urllib_parse,
find_xpath_attr, find_xpath_attr,
compat_urlparse,
) )
class BrightcoveIE(InfoExtractor): class BrightcoveIE(InfoExtractor):
@ -39,15 +40,15 @@ class BrightcoveIE(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)
query = mobj.group('query') query_str = mobj.group('query')
query = compat_urlparse.parse_qs(query_str)
m_video_id = re.search(r'videoPlayer=(\d+)', query) videoPlayer = query.get('@videoPlayer')
if m_video_id is not None: if videoPlayer:
video_id = m_video_id.group(1) return self._get_video_info(videoPlayer[0], query_str)
return self._get_video_info(video_id, query)
else: else:
player_key = self._search_regex(r'playerKey=(.+?)(&|$)', query, 'playlist_id') player_key = query['playerKey']
return self._get_playlist_info(player_key) return self._get_playlist_info(player_key[0])
def _get_video_info(self, video_id, query): def _get_video_info(self, video_id, query):
request_url = self._FEDERATED_URL_TEMPLATE % query request_url = self._FEDERATED_URL_TEMPLATE % query

View file

@ -35,6 +35,11 @@ try:
except ImportError: # Python 2 except ImportError: # Python 2
from urlparse import urlparse as compat_urllib_parse_urlparse from urlparse import urlparse as compat_urllib_parse_urlparse
try:
import urllib.parse as compat_urlparse
except ImportError: # Python 2
import urlparse as compat_urlparse
try: try:
import http.cookiejar as compat_cookiejar import http.cookiejar as compat_cookiejar
except ImportError: # Python 2 except ImportError: # Python 2