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
[ie/joqrag] Add extractor #8384
Conversation
Support radio "超!A&G+" on Nippon Cultural Broadcasting (JOQR).
Co-authored-by: garret <garret1317@yandex.com>
Co-authored-by: garret <garret1317@yandex.com>
Co-authored-by: garret <garret1317@yandex.com>
Co-authored-by: garret <garret1317@yandex.com>
Co-authored-by: garret <garret1317@yandex.com>
Hi there, I'm going to add a change: The "joqrag" site stops at night and plays a loop video containing their logo. I think that the extractor should not download the stream but treat it as an "up_coming" live and " Now convert this PR to draft. |
Co-authored-by: bashonly <bashonly@bashonly.com>
A failed download will return False and make _search_regex() failed: TypeError: expected string or bytes-like object
- Order of imports - More readable url regex - More strict and safer quotes matching - Shorter inner function name - Using single quotes - More lenient start time regex - Inlined description - More readable code for constructing message - Raising exceptions if no m3u8 formats Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
yt_dlp/extractor/joqrag.py
Outdated
_VALID_URL = [r'https?://www\.uniqueradio\.jp/agplayer5/player\.php', | ||
r'https?://www\.uniqueradio\.jp/agplayer5/inc-player-hls\.php', |
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.
_VALID_URL = [r'https?://www\.uniqueradio\.jp/agplayer5/player\.php', | |
r'https?://www\.uniqueradio\.jp/agplayer5/inc-player-hls\.php', | |
_VALID_URL = [r'https?://www\.uniqueradio\.jp/agplayer5/(?:player|inc-player-hls)\.php', |
yt_dlp/extractor/joqrag.py
Outdated
def _extract_metadata(self, variable, html, name): | ||
return clean_html(urllib.parse.unquote_plus(self._search_regex( | ||
rf'var\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1', | ||
html, name, group='value', default=''))) or None |
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.
it's always non-fatal so the name
param doesn't really matter
def _extract_metadata(self, variable, html, name): | |
return clean_html(urllib.parse.unquote_plus(self._search_regex( | |
rf'var\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1', | |
html, name, group='value', default=''))) or None | |
def _extract_metadata(self, variable, html): | |
return clean_html(urllib.parse.unquote_plus(self._search_regex( | |
rf'var\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1', | |
html, 'metadata', group='value', default=''))) or None |
yt_dlp/extractor/joqrag.py
Outdated
metadata = self._download_webpage( | ||
'https://www.uniqueradio.jp/aandg', video_id, | ||
note='Downloading metadata', errnote='Failed to download metadata') | ||
title = self._extract_metadata('Program_name', metadata, 'program title') |
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.
title = self._extract_metadata('Program_name', metadata, 'program title') | |
title = self._extract_metadata('Program_name', metadata) |
yt_dlp/extractor/joqrag.py
Outdated
'id': video_id, | ||
'title': title, | ||
'channel': '超!A&G+', | ||
'description': self._extract_metadata('Program_text', metadata, 'program description'), |
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.
'description': self._extract_metadata('Program_text', metadata, 'program description'), | |
'description': self._extract_metadata('Program_text', metadata), |
yt_dlp/extractor/joqrag.py
Outdated
start_time = self._search_regex( | ||
r'<h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(?P<time>\d{1,2}:\d{1,2})', | ||
self._download_webpage( | ||
f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id, | ||
note=f'Downloading program list of {date}', fatal=False, | ||
errnote=f'Failed to download program list of {date}') or '', | ||
'start time of the first program', default=None, group='time') |
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.
could make this a little less busy
start_time = self._search_regex( | |
r'<h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(?P<time>\d{1,2}:\d{1,2})', | |
self._download_webpage( | |
f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id, | |
note=f'Downloading program list of {date}', fatal=False, | |
errnote=f'Failed to download program list of {date}') or '', | |
'start time of the first program', default=None, group='time') | |
start_time = self._search_regex( | |
r'<h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(\d{1,2}:\d{1,2})', | |
self._download_webpage( | |
f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id, | |
note=f'Downloading program list of {date}', fatal=False, | |
errnote=f'Failed to download program list of {date}') or '', | |
'start time', default=None) |
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
Authored by: pzhlkj6612
IMPORTANT: PRs without the template will be CLOSED
Description of your pull request and other information
Hi! I would like to let yt-dlp support radio "超!A&G+" on Nippon Cultural Broadcasting (JOQR).
Please do not to be confused with Radiko (radiko.py).
Template
Before submitting a pull request make sure you have:
In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:
What is the purpose of your pull request?
Copilot Summary
🤖 Generated by Copilot at 4f478a9
Summary
📻🇯🇵🎙️
Add support for extracting live streams from JOQR radio station. Add
joqrag.py
module withJoqrAgIE
class and import it in_extractors.py
.Walkthrough
JoqrAgIE
class fromjoqrag.py
module in_extractors.py
(link)JoqrAgIE
class injoqrag.py
module that inherits fromInfoExtractor
base class (link)suitable
andie_key
methods to match the JOQR website url and return the extractor key (link)_real_extract
method to parse the webpage and extract the metadata and the m3u8 url usingself._html_search_regex
andself._extract_m3u8_formats
methods (link)id
,title
,formats
,is_live
, etc. (link)joqrag.py
module that checks theid
,title
,ext
, andis_live
fields of the extracted information (link)