]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/stanfordoc.py
[ie/mlbtv] Fix extraction (#10296)
[yt-dlp.git] / yt_dlp / extractor / stanfordoc.py
index ae3dd13807d0f9f46939f6dfab066a75eddd1ed1..ab41091cff4170b41c181b6f8d29b49277f5964f 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
 import re
 
 from .common import InfoExtractor
@@ -21,11 +19,11 @@ class StanfordOpenClassroomIE(InfoExtractor):
             'id': 'PracticalUnix_intro-environment',
             'ext': 'mp4',
             'title': 'Intro Environment',
-        }
+        },
     }
 
     def _real_extract(self, url):
-        mobj = re.match(self._VALID_URL, url)
+        mobj = self._match_valid_url(url)
 
         if mobj.group('course') and mobj.group('video'):  # A specific video
             course = mobj.group('course')
@@ -36,12 +34,12 @@ def _real_extract(self, url):
                 'upload_date': None,
             }
 
-            baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
-            xmlUrl = baseUrl + video + '.xml'
-            mdoc = self._download_xml(xmlUrl, info['id'])
+            base_url = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
+            xml_url = base_url + video + '.xml'
+            mdoc = self._download_xml(xml_url, info['id'])
             try:
                 info['title'] = mdoc.findall('./title')[0].text
-                info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text
+                info['url'] = base_url + mdoc.findall('./videoFile')[0].text
             except IndexError:
                 raise ExtractorError('Invalid metadata XML file')
             return info
@@ -68,7 +66,7 @@ def _real_extract(self, url):
 
             links = orderedSet(re.findall(r'<a href="(VideoPage\.php\?[^"]+)">', coursepage))
             info['entries'] = [self.url_result(
-                'http://openclassroom.stanford.edu/MainFolder/%s' % unescapeHTML(l)
+                f'http://openclassroom.stanford.edu/MainFolder/{unescapeHTML(l)}',
             ) for l in links]
             return info
         else:  # Root page
@@ -80,12 +78,12 @@ def _real_extract(self, url):
             }
             info['title'] = info['id']
 
-            rootURL = 'http://openclassroom.stanford.edu/MainFolder/HomePage.php'
-            rootpage = self._download_webpage(rootURL, info['id'],
+            root_url = 'http://openclassroom.stanford.edu/MainFolder/HomePage.php'
+            rootpage = self._download_webpage(root_url, info['id'],
                                               errnote='Unable to download course info page')
 
             links = orderedSet(re.findall(r'<a href="(CoursePage\.php\?[^"]+)">', rootpage))
             info['entries'] = [self.url_result(
-                'http://openclassroom.stanford.edu/MainFolder/%s' % unescapeHTML(l)
+                f'http://openclassroom.stanford.edu/MainFolder/{unescapeHTML(l)}',
             ) for l in links]
             return info