From c9606e0968aebe25e61fbef06f4a1a3278bdcd65 Mon Sep 17 00:00:00 2001 From: Alfonso Date: Mon, 6 Feb 2023 11:28:44 +0100 Subject: [PATCH] [FileMoonIE] Add extractor for filemoon.sx --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/filemoon.py | 45 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 youtube_dl/extractor/filemoon.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 96b27b179..1b0ae3cf0 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -376,6 +376,7 @@ from .fc2 import ( FC2EmbedIE, ) from .fczenit import FczenitIE +from .filemoon import FileMoonIE from .fifa import FifaIE from .filmon import ( FilmOnIE, diff --git a/youtube_dl/extractor/filemoon.py b/youtube_dl/extractor/filemoon.py new file mode 100644 index 000000000..5050a0967 --- /dev/null +++ b/youtube_dl/extractor/filemoon.py @@ -0,0 +1,45 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from .. import utils +from ..utils import js_to_json + + +class FileMoonIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?filemoon\.sx/./(?P\w+)(/(?P.*))*' + _TEST = { + 'url': 'https://filemoon.sx/e/dw40rxrzruqz', + 'md5': '5a713742f57ac4aef29b74733e8dda01', + 'info_dict': { + 'id': 'dw40rxrzruqz', + 'title': 'dw40rxrzruqz', + 'ext': 'mp4' + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + m = self._VALID_URL_RE.match(url) + title = m.group('title') + if not title: + title = video_id + + webpage = self._download_webpage(url, video_id) + matches = re.findall(r'(eval.*?)<\/script>', webpage, flags=re.DOTALL) + packed = matches[-1] + unpacked = utils.decode_packed_codes(packed) + jwplayer_sources = self._parse_json( + self._search_regex( + r"(?s)player\.setup\(\{sources:(.*?])", unpacked, 'jwplayer sources'), + video_id, transform_source=js_to_json) + + formats = self._parse_jwplayer_formats(jwplayer_sources, video_id) + + return { + 'id': video_id, + 'title': title, + 'formats': formats + }