From fd69e827b7048c2816fb2a9cab8002bec8a33af8 Mon Sep 17 00:00:00 2001 From: Valentin Villenave Date: Wed, 30 Jun 2021 10:07:15 +0200 Subject: [PATCH] [WIP-creacast] Add support for creacast.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code doesn’t work, but as a beginner I’m having a hard time figuring out how to make it functional. Could someone give me any pointers? --- youtube_dl/extractor/creacast.py | 60 ++++++++++++++++++++++++++++++ youtube_dl/extractor/extractors.py | 1 + 2 files changed, 61 insertions(+) create mode 100644 youtube_dl/extractor/creacast.py diff --git a/youtube_dl/extractor/creacast.py b/youtube_dl/extractor/creacast.py new file mode 100644 index 000000000..b3aa93b71 --- /dev/null +++ b/youtube_dl/extractor/creacast.py @@ -0,0 +1,60 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class CreaCastIE(InfoExtractor): + _VALID_URL = r'''(?x) + https?://(?:\w+\.)?creacast\.com/ + (?: + channel/\w+/[^/]*iid=(?P\d+)| + play.php\?k=(?P[^/?#&]+) + )''' + _TESTS = [ + { + 'url': 'https://www.creacast.com/play.php?k=GHGGRuQfeaJ4g4r6cpGSe4', + 'md5': 'a524c0a6096c583345603777596b439c', + 'info_dict': { + 'id': 'GHGGRuQfeaJ4g4r6cpGSe4', + 'ext': 'mp4', + 'title': 'Strasbourg VOD' + } + }, + { + 'url': 'https://www.creacast.com/channel/strasbourg/?sort=v&iid=5444&display=vod', + 'md5': 'TBC', + 'info_dict': { + 'id': '5444', + 'ext': 'mp4', + 'title': 'Conseils | Strasbourg.eu' + } + } + ] + + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + data = self._parse_json( + self._search_regex( + r'(?s)runParams\s*=\s*({.+?})\s*;?\s*var', + webpage, 'runParams'), + video_id) + + formats = self._extract_m3u8_formats( + data['replyStreamUrl'], video_id, 'mp4', + entry_protocol='m3u8_native', m3u8_id='hls') + + print("toto\n\n") + + title = self._html_search_regex(r'(.+?)', webpage, 'title') + + return { + 'id': video_id, + 'title': title, + 'description': self._og_search_description(webpage), + 'uploader': self._search_regex(r']+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), + 'formats': formats, + } diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 6e8fc3961..f750e2a7c 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -255,6 +255,7 @@ from .contv import CONtvIE from .corus import CorusIE from .cracked import CrackedIE from .crackle import CrackleIE +from .creacast import CreaCastIE from .crooksandliars import CrooksAndLiarsIE from .crunchyroll import ( CrunchyrollIE,