Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doodstream] add so domain and manage all links #3119

Closed
wants to merge 6 commits into from
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 32 additions & 6 deletions yt_dlp/extractor/doodstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import time

from .common import InfoExtractor
from ..compat import compat_urlparse


class DoodStreamIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?dood\.(?:to|watch)/[ed]/(?P<id>[a-z0-9]+)'
_VALID_URL = r'https?://(?:www\.)?dood\.(?:to|watch|so)/[ed]/(?P<id>[a-z0-9]+)'
_TESTS = [{
'url': 'http://dood.to/e/5s1wmbdacezb',
'md5': '4568b83b31e13242b3f1ff96c55f0595',
Expand Down Expand Up @@ -40,18 +41,43 @@ class DoodStreamIE(InfoExtractor):
'description': 'Stacy Cruz Cute ALLWAYSWELL | DoodStream.com',
'thumbnail': 'https://img.doodcdn.com/snaps/8edqd5nppkac3x8u.jpg',
}
}, {
'url': 'https://dood.so/d/wlihoael8uog',
'md5': '5144b8066c68c5a5a3321eb623ab7272',
'info_dict': {
'id': 'wlihoael8uog',
'ext': 'mp4',
'title': 'VID 20220319 161659',
'description': 'VID 20220319 161659',
'thumbnail': 'https://img.doodcdn.com/snaps/8edqd5nppkac3x8u.jpg',
}
}]

def _real_extract(self, url):
parts = compat_urlparse.urlsplit(url)
hostname = parts.hostname
path = parts.path
video_id = self._match_id(url)
This conversation was marked as resolved.
Show resolved Hide resolved
url = f'https://dood.to/e/{video_id}'

title = None
description = None
if path.startswith('/d/'):
webpage = self._download_webpage(url, video_id)
iframe = self._html_search_regex(r'<iframe +src="([^"]+)"', webpage, 'iframe')
This conversation was marked as resolved.
Show resolved Hide resolved
url = f'https://{hostname}{iframe}'
title = self._html_search_meta(['og:title', 'twitter:title'], webpage, default=None)
description = self._html_search_meta(
['og:description', 'description', 'twitter:description'], webpage, default=None)
This conversation was marked as resolved.
Show resolved Hide resolved

webpage = self._download_webpage(url, video_id)

title = self._html_search_meta(['og:title', 'twitter:title'], webpage, default=None)
if title is None:
title = self._html_search_meta(['og:title', 'twitter:title'], webpage, default=None)
thumb = self._html_search_meta(['og:image', 'twitter:image'], webpage, default=None)
token = self._html_search_regex(r'[?&]token=([a-z0-9]+)[&\']', webpage, 'token')
description = self._html_search_meta(
['og:description', 'description', 'twitter:description'], webpage, default=None)
if description is None:
description = self._html_search_meta(
['og:description', 'description', 'twitter:description'], webpage, default=None)

headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/66.0',
Expand All @@ -60,7 +86,7 @@ def _real_extract(self, url):

pass_md5 = self._html_search_regex(r'(/pass_md5.*?)\'', webpage, 'pass_md5')
final_url = ''.join((
self._download_webpage(f'https://dood.to{pass_md5}', video_id, headers=headers),
self._download_webpage(f'https://{hostname}{pass_md5}', video_id, headers=headers),
*(random.choice(string.ascii_letters + string.digits) for _ in range(10)),
f'?token={token}&expiry={int(time.time() * 1000)}',
))
Expand Down