-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[hanime] Add new extractor #24328
[hanime] Add new extractor #24328
Conversation
Read coding conventions. |
Calculate TBR from Filesize and Duration, if provided Use parsing and conversion functions
on int_or_none and float_or_none
Did that cover all convention recommendations or I still missed anything? |
youtube_dl/extractor/hanime.py
Outdated
video_slug = self._match_id(url) | ||
|
||
webpage = self._download_webpage(url, video_slug) | ||
page_json = self._html_search_regex(r'window.__NUXT__=(.+?);<\/script>', webpage, 'Inline JSON') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Extract dict if you expect dict.
- Relax regex.
- Escape dots.
youtube_dl/extractor/hanime.py
Outdated
|
||
webpage = self._download_webpage(url, video_slug) | ||
page_json = self._html_search_regex(r'window.__NUXT__=(.+?);<\/script>', webpage, 'Inline JSON') | ||
page_json = self._parse_json(page_json, video_slug).get('state').get('data').get('video').get('hentai_video') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read coding conventions on mandatory data.
youtube_dl/extractor/hanime.py
Outdated
'API Call', headers={'X-Directive': 'api'}).get('videos_manifest').get('servers')[0].get('streams') | ||
|
||
title = page_json.get('name') or api_json.get[0].get('video_stream_group_id') | ||
tags = [t.get('text') for t in page_json.get('hentai_tags')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaks.
youtube_dl/extractor/hanime.py
Outdated
|
||
formats = [] | ||
for f in api_json: | ||
item_url = url_or_none(f.get('url')) or url_or_none('https://hanime.tv/api/v1/m3u8s/%s.m3u8' % f.get('id')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think everything was addressed. Hopefully got the meaning of the single-words right xD
Iterate over server list instead of always using first index Add a couple fallbacks
youtube_dl/extractor/hanime.py
Outdated
'https://members.hanime.tv/api/v3/videos_manifests/%s' % video_slug, | ||
video_slug, | ||
'API Call', headers={'X-Directive': 'api'}), lambda x: x['videos_manifest']['servers'], list) or [] | ||
title = page_json.get('name') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mandatory.
youtube_dl/extractor/hanime.py
Outdated
video_slug, | ||
'API Call', headers={'X-Directive': 'api'}), lambda x: x['videos_manifest']['servers'], list) or [] | ||
title = page_json.get('name') | ||
duration = parse_duration('%sms' % page_json.get('duration_in_ms')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: float_or_none, not parse_duration.
youtube_dl/extractor/hanime.py
Outdated
title = page_json.get('name') | ||
duration = parse_duration('%sms' % page_json.get('duration_in_ms')) | ||
tags = [] | ||
for tag in page_json.get('hentai_tags'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaks.
youtube_dl/extractor/hanime.py
Outdated
|
||
def _real_extract(self, url): | ||
video_slug = self._match_id(url) | ||
page_json = self._html_search_regex(r'<script>.+__NUXT__=(.+?);<\/script>', self._download_webpage(url, video_slug), 'Inline JSON') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed.
youtube_dl/extractor/hanime.py
Outdated
for stream in server['streams']: | ||
if stream.get('compatibility') != 'all': | ||
continue | ||
item_url = sanitize_url(stream.get('url')) or sanitize_url('https://hanime.tv/api/v1/m3u8s/%s.m3u8' % stream.get('id')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed.
format = { | ||
'width': width, | ||
'height': height, | ||
'filesize_approx': float_or_none(parse_filesize('%sMb' % stream.get('filesize_mbs'))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
youtube_dl/extractor/hanime.py
Outdated
{'preference': 0, 'id': 'Poster', 'url': page_json.get('poster_url')}, | ||
{'preference': 1, 'id': 'Cover', 'url': page_json.get('cover_url')}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed.
Since I'm not an actual programmer, could I kindly ask to get more than a couple words on the requested changes? Laconic answers can (and some have) become a time-consuming guessing game 😕 |
Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
Extractor for hanime.tv (NSFW) using as many fields as they provide