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
[erocast] Add new extractor for erocast.me #31631
base: master
Are you sure you want to change the base?
Conversation
As the linked issue didn't use the Site Support template, please complete the template for this site, posted either here, or in the issue, or in a new issue. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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.
Thanks for your work!
I've made some suggestions.
|
||
# The Song data is in a script tag with the following format: | ||
# (see https://github.com/ytdl-org/youtube-dl/issues/31203#issuecomment-1259867716) | ||
searchPattern = r'<script>var song_data_' + str(video_id) + r' = (.+?)<\/script>' |
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.
- relax the RE
- when might
video_id
not be a string? - if the
.+
might contain newlines, user'(?s)...
or use[\s\S]+
searchPattern = r'<script>var song_data_' + str(video_id) + r' = (.+?)<\/script>' | |
searchPattern = r'<script\b[^>]*>var\s+song_data_%s\s*=\s*(.+?)</script>' % re.escape(video_id) |
jsonObject = self._parse_json(jsonString, None, fatal=False) | ||
audio_url = jsonObject['stream_url'] | ||
title = jsonObject['title'] | ||
user_name = jsonObject['user']['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.
Optional metadata, shouldn't crash extraction:
user_name = jsonObject['user']['name'] | |
user_name = traverse_obj(jsonObject, ('user', 'name'), expected_type=lambda x: x.strip() or None) |
formats = [] | ||
formats.extend(self._extract_m3u8_formats( | ||
audio_url, video_id, 'mp4', 'm3u8_native', | ||
m3u8_id='hls', fatal=False)) |
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.
Call _sort_formats()
:
formats = [] | |
formats.extend(self._extract_m3u8_formats( | |
audio_url, video_id, 'mp4', 'm3u8_native', | |
m3u8_id='hls', fatal=False)) | |
formats = self._extract_m3u8_formats( | |
audio_url, video_id, 'mp4', 'm3u8_native', | |
m3u8_id='hls', fatal=False) | |
self._sort_formats(formats) |
from __future__ import unicode_literals | ||
|
||
from .common import InfoExtractor | ||
|
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.
from ..utils import traverse_obj |
# The Song data is in a script tag with the following format: | ||
# (see https://github.com/ytdl-org/youtube-dl/issues/31203#issuecomment-1259867716) | ||
searchPattern = r'<script>var song_data_' + str(video_id) + r' = (.+?)<\/script>' | ||
jsonString = self._html_search_regex(searchPattern, webpage, 'data') |
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.
Maybe make the text for the search more specific:
jsonString = self._html_search_regex(searchPattern, webpage, 'data') | |
jsonString = self._html_search_regex(searchPattern, webpage, 'song data') |
@@ -353,6 +353,8 @@ | |||
from .embedly import EmbedlyIE | |||
from .engadget import EngadgetIE | |||
from .eporner import EpornerIE | |||
from .erocast import ErocastIE | |||
|
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.
Unwanted space
I'm sad this seemingly got stuck, I found an audio file on Erocast recently and the site is not particularly screen-reader friendly. I know enough to get the audio file out using developer tools but not enough to write code to automate it based on a URL. By this point I'd guess the original PR author isn't working on it anymore. |
Hi all, I've had a look at the code by the original author and I've noticed there wasn't any functionality to allow downloads of playlists from the site. I decided to have a look over the last few days and I've managed to successfully implement the feature to download playlists from erocast.me. Shall I create a new PR for this feature as the original author doesn't seem to be working on this anymore like Simon818 remarked? While creating a new PR I can also add the suggestions mentioned above by dirkf so it can all be in one neat package and we can close this PR for good. |
@aaron-tan That's awesome. I think you should go ahead and submit it, particularly if it's already working on both playlists and individual tracks. We have no idea when the original PR author is going to respond and you have something that works today. |
Build on code from PR ytdl-org#31631. - Add playlist info extractor to download playlists - Refactor code from suggestions by @dirkf
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])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
Explanation of your pull request in arbitrary form goes here. Please make sure the description explains the purpose and effect of your pull request and is worded well enough to be understood. Provide as much context and examples as possible.