mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-08-22 22:34:01 -07:00
Apply suggestions from code review
Co-authored-by: dirkf <fieldhouse@gmx.net>
This commit is contained in:
parent
c9606e0968
commit
87393c7566
1 changed files with 9 additions and 9 deletions
|
@ -4,12 +4,14 @@ from __future__ import unicode_literals
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from .. import utils
|
from ..utils import (
|
||||||
from ..utils import js_to_json
|
decode_packed_codes,
|
||||||
|
js_to_json,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FileMoonIE(InfoExtractor):
|
class FileMoonIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?filemoon\.sx/./(?P<id>\w+)(/(?P<title>.*))*'
|
_VALID_URL = r'https?://(?:www\.)?filemoon\.sx/./(?P<id>\w+)(?:/(?P<title>.+))*'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://filemoon.sx/e/dw40rxrzruqz',
|
'url': 'https://filemoon.sx/e/dw40rxrzruqz',
|
||||||
'md5': '5a713742f57ac4aef29b74733e8dda01',
|
'md5': '5a713742f57ac4aef29b74733e8dda01',
|
||||||
|
@ -21,19 +23,17 @@ class FileMoonIE(InfoExtractor):
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id, title = re.match(self._VALID_URL, url).group('id', 'title')
|
||||||
m = self._VALID_URL_RE.match(url)
|
|
||||||
title = m.group('title')
|
|
||||||
if not title:
|
if not title:
|
||||||
title = video_id
|
title = video_id
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
matches = re.findall(r'(eval.*?)<\/script>', webpage, flags=re.DOTALL)
|
matches = re.findall(r'(?s)(eval.*?)<\/script>', webpage)
|
||||||
packed = matches[-1]
|
packed = matches[-1]
|
||||||
unpacked = utils.decode_packed_codes(packed)
|
unpacked = decode_packed_codes(packed)
|
||||||
jwplayer_sources = self._parse_json(
|
jwplayer_sources = self._parse_json(
|
||||||
self._search_regex(
|
self._search_regex(
|
||||||
r"(?s)player\.setup\(\{sources:(.*?])", unpacked, 'jwplayer sources'),
|
r'(?s)player\s*\.\s*setup\s*\(\s*\{\s*sources\s*:\s*(.*?])', unpacked, 'jwplayer sources'),
|
||||||
video_id, transform_source=js_to_json)
|
video_id, transform_source=js_to_json)
|
||||||
|
|
||||||
formats = self._parse_jwplayer_formats(jwplayer_sources, video_id)
|
formats = self._parse_jwplayer_formats(jwplayer_sources, video_id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue