]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
BrightcoveIE: Use parse_qs to extract the fields of the query (closes #1032)
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 12 Jul 2013 12:53:28 +0000 (14:53 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 12 Jul 2013 12:53:28 +0000 (14:53 +0200)
Add a compat_urlparse to utils.

youtube_dl/extractor/brightcove.py
youtube_dl/utils.py

index 450b4a4063ee4bd99b6dc03f33a1bed20832b5e0..71e3c7883338154eea0c3d369a0fdd0bee828e26 100644 (file)
@@ -6,6 +6,7 @@ from .common import InfoExtractor
 from ..utils import (
     compat_urllib_parse,
     find_xpath_attr,
+    compat_urlparse,
 )
 
 class BrightcoveIE(InfoExtractor):
@@ -39,15 +40,15 @@ class BrightcoveIE(InfoExtractor):
 
     def _real_extract(self, 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)
-        if m_video_id is not None:
-            video_id = m_video_id.group(1)
-            return self._get_video_info(video_id, query)
+        videoPlayer = query.get('@videoPlayer')
+        if videoPlayer:
+            return self._get_video_info(videoPlayer[0], query_str)
         else:
-            player_key = self._search_regex(r'playerKey=(.+?)(&|$)', query, 'playlist_id')
-            return self._get_playlist_info(player_key)
+            player_key = query['playerKey']
+            return self._get_playlist_info(player_key[0])
 
     def _get_video_info(self, video_id, query):
         request_url = self._FEDERATED_URL_TEMPLATE % query
index 31db1bf8cbac0e590b804e542fd9802eebd2df92..532ca585d295b2dadd40b4f84333751a64286d56 100644 (file)
@@ -35,6 +35,11 @@ try:
 except ImportError: # Python 2
     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:
     import http.cookiejar as compat_cookiejar
 except ImportError: # Python 2