]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/vidlii.py
[ie/crunchyroll] Fix stream extraction (#10005)
[yt-dlp.git] / yt_dlp / extractor / vidlii.py
index ce7487ec1619b8997505a2bcdf1d8e84f7c7428d..44353b7fc45a19e6848dfa9364a57267a3ae652d 100644 (file)
@@ -1,11 +1,9 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import re
 
 from .common import InfoExtractor
+from ..networking import HEADRequest
 from ..utils import (
-    HEADRequest,
+    format_field,
     float_or_none,
     get_element_by_id,
     int_or_none,
@@ -72,6 +70,7 @@ def _real_extract(self, url):
             r'src\s*:\s*(["\'])(?P<url>(?:https?://)?(?:(?!\1).)+)\1',
             webpage) or []]
         for source in sources:
+            source = urljoin(url, source)
             height = int(self._search_regex(r'(\d+).mp4', source, 'height', default=360))
             if self._request_webpage(HEADRequest(source), video_id, f'Checking {height}p url', errnote=False):
                 formats.append({
@@ -79,7 +78,6 @@ def _real_extract(self, url):
                     'format_id': f'{height}p',
                     'height': height,
                 })
-        self._sort_formats(formats)
 
         title = self._search_regex(
             (r'<h1>([^<]+)</h1>', r'<title>([^<]+) - VidLii<'), webpage,
@@ -102,7 +100,7 @@ def _real_extract(self, url):
         uploader = self._search_regex(
             r'<div[^>]+class=["\']wt_person[^>]+>\s*<a[^>]+\bhref=["\']/user/[^>]+>([^<]+)',
             webpage, 'uploader', fatal=False)
-        uploader_url = 'https://www.vidlii.com/user/%s' % uploader if uploader else None
+        uploader_url = format_field(uploader, None, 'https://www.vidlii.com/user/%s')
 
         upload_date = unified_strdate(self._html_search_meta(
             'datePublished', webpage, default=None) or self._search_regex(