]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/camdemy.py
[ie/mlbtv] Fix extraction (#10296)
[yt-dlp.git] / yt_dlp / extractor / camdemy.py
index 8f0c6c545c35312813bb461b3218f868a660fdd2..34dc095af86b766d46b8b95cf94ff23e85e1e8ab 100644 (file)
@@ -1,13 +1,7 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import re
+import urllib.parse
 
 from .common import InfoExtractor
-from ..compat import (
-    compat_urllib_parse_urlencode,
-    compat_urlparse,
-)
 from ..utils import (
     clean_html,
     parse_duration,
@@ -31,7 +25,7 @@ class CamdemyIE(InfoExtractor):
             'duration': 1591,
             'upload_date': '20130114',
             'view_count': int,
-        }
+        },
     }, {
         # With non-empty description
         # webpage returns "No permission or not login"
@@ -45,7 +39,7 @@ class CamdemyIE(InfoExtractor):
             'description': 'md5:2a9f989c2b153a2342acee579c6e7db6',
             'creator': 'evercam',
             'duration': 318,
-        }
+        },
     }, {
         # External source (YouTube)
         'url': 'http://www.camdemy.com/media/14842',
@@ -79,12 +73,12 @@ def _real_extract(self, url):
 
         title = oembed_obj['title']
         thumb_url = oembed_obj['thumbnail_url']
-        video_folder = compat_urlparse.urljoin(thumb_url, 'video/')
+        video_folder = urllib.parse.urljoin(thumb_url, 'video/')
         file_list_doc = self._download_xml(
-            compat_urlparse.urljoin(video_folder, 'fileList.xml'),
+            urllib.parse.urljoin(video_folder, 'fileList.xml'),
             video_id, 'Downloading filelist XML')
         file_name = file_list_doc.find('./video/item/fileName').text
-        video_url = compat_urlparse.urljoin(video_folder, file_name)
+        video_url = urllib.parse.urljoin(video_folder, file_name)
 
         # Some URLs return "No permission or not login" in a webpage despite being
         # freely available via oembed JSON URL (e.g. http://www.camdemy.com/media/13885)
@@ -120,35 +114,35 @@ class CamdemyFolderIE(InfoExtractor):
             'id': '450',
             'title': '信號與系統 2012 & 2011 (Signals and Systems)',
         },
-        'playlist_mincount': 145
+        'playlist_mincount': 145,
     }, {
         # links without trailing slash
         # and multi-page
         'url': 'http://www.camdemy.com/folder/853',
         'info_dict': {
             'id': '853',
-            'title': '科學計算 - 使用 Matlab'
+            'title': '科學計算 - 使用 Matlab',
         },
-        'playlist_mincount': 20
+        'playlist_mincount': 20,
     }, {
         # with displayMode parameter. For testing the codes to add parameters
         'url': 'http://www.camdemy.com/folder/853/?displayMode=defaultOrderByOrg',
         'info_dict': {
             'id': '853',
-            'title': '科學計算 - 使用 Matlab'
+            'title': '科學計算 - 使用 Matlab',
         },
-        'playlist_mincount': 20
+        'playlist_mincount': 20,
     }]
 
     def _real_extract(self, url):
         folder_id = self._match_id(url)
 
         # Add displayMode=list so that all links are displayed in a single page
-        parsed_url = list(compat_urlparse.urlparse(url))
-        query = dict(compat_urlparse.parse_qsl(parsed_url[4]))
+        parsed_url = list(urllib.parse.urlparse(url))
+        query = dict(urllib.parse.parse_qsl(parsed_url[4]))
         query.update({'displayMode': 'list'})
-        parsed_url[4] = compat_urllib_parse_urlencode(query)
-        final_url = compat_urlparse.urlunparse(parsed_url)
+        parsed_url[4] = urllib.parse.urlencode(query)
+        final_url = urllib.parse.urlunparse(parsed_url)
 
         page = self._download_webpage(final_url, folder_id)
         matches = re.findall(r"href='(/media/\d+/?)'", page)