ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.17k stars 9.93k forks source link

Documaniatv not supported #30300

Open JoseLingo opened 2 years ago

JoseLingo commented 2 years ago

https://www.documaniatv.com/ not supported

Example url: https://www.documaniatv.com/naturaleza/japon-salvaje-2-las-islas-del-sureste-video_2746bf479.html Example url: https://www.documaniatv.com/viajes/las-islas-griegas-con-julia-bradbury-4-las-esporadas-video_12f770b7a.html

dirkf commented 2 years ago

Looks like it would need yt-dl to implement PrivacyPass, as the site implements a Cloudflare/hcaptcha block against non-JS clients (plus points for using hcaptcha instead of G recaptcha, though).

Once you can download the page without JS, have something like this in a new extractor/documaniatv.py:

# code header boilerplate and imports as required

class DocumaniaTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www.)?documaniatv\.com/[\w/-]+\w-video_(?P<id>[a-f\d]+)\.html'

    def _real_extract(self, url):
        video_id = self._match_id(url)
        # insert magic PrivacyPass or other hack to bypass Cloudflare site breakage here 
        webpage = self._download_webpage(url, video_id)
        video_data = self._search_regex(
            r'(?s)jwplayer\s*\(\s*"%s"\s*\)\s*\.\s*setup\s*\(\s*({.+?})\s*\)\s*;' % video_id,
            webpage, 'jwplayer data')
        video_data = self._parse_json(video_data, video_id)
        video_url = video_data['file']
        title = self._og_search_title(webpage)
        return {
            'id': video_id,
            'url': video_url,
            'title': title,
            'thumbnail': self._og_search_thumbnail(webpage),
            'width': int_or_none(self._og_search_property('video:width', webpage, fatal=False)),
            'height': int_or_none(self._og_search_property('video:height', webpage, fatal=False)),
            'duration': int_or_none(self._og_search_property('video:duration', webpage, fatal=False)),
        }
october262 commented 2 years ago

for this test link - https://www.documaniatv.com/naturaleza/japon-salvaje-2-las-islas-del-sureste-video_2746bf479.html if you have a browser addon that allows right click, just right click on the video and select save as and you can download the video as mp4

JoseLingo commented 2 years ago

Wow many thanks everyone!!! It works like a charm