fix: add new extractor for QingTing

This commit is contained in:
wangchangren 2022-06-16 20:43:37 +08:00
parent 16e7b15f76
commit 9ff181a1ab
2 changed files with 36 additions and 5 deletions

View File

@ -975,7 +975,10 @@ from .presstv import PressTVIE
from .prosiebensat1 import ProSiebenSat1IE
from .puls4 import Puls4IE
from .pyvideo import PyvideoIE
from .qingting import QingTingIE
from .qingting import (
QingTingMobileIE,
QingTingDeskTopIE,
)
from .qqmusic import (
QQMusicIE,
QQMusicSingerIE,

View File

@ -5,8 +5,9 @@ import re
from .common import InfoExtractor
from youtube_dl import utils
class QingTingIE(InfoExtractor):
class QingTingMobileIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'(?:https?://)?(?:www\.)?m\.(?:qingting\.fm|qtfm\.cn)/vchannels/\d+/programs/(?P<id>\d+)'
_TEST = {
@ -25,10 +26,10 @@ class QingTingIE(InfoExtractor):
title = self._html_search_regex(r'(?s)<title\b[^>]*>(.*)</title>', webpage, 'title', default=None) or self._og_search_title(webpage)
url = self._search_regex(
r'''("|')audioUrl\1\s*:\s*("|')(?P<url>(?:(?!\2).)*)\2''',
webpage, 'audio URL')
test_url = url_or_none(url)
webpage, 'audio URL', group="url")
test_url = utils.url_or_none(url)
if not test_url:
raise ExtractorError('Invalid audio URL %s' % (url, ))
raise utils.ExtractorError('Invalid audio URL %s' % (url,))
url = test_url
return {
'id': video_id,
@ -36,3 +37,30 @@ class QingTingIE(InfoExtractor):
'ext': 'mp3',
'url': url,
}
class QingTingDeskTopIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'(?:https?://)?(?:www\.)?(?:qingting\.fm|qtfm\.cn)/channels/\d+/programs/(?P<id>\d+)'
_TEST = {
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd1888fb3c',
'info_dict': {
'id': '22257411',
'ext': 'mp3',
'title': '用了十年才修改,谁在乎教科书?-睡前消息-蜻蜓FM听头条',
}
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'(?s)<title\b[^>]*>(.*)</title>', webpage, 'title',
default=None) or self._og_search_title(webpage)
url = self._search_regex(
r'''("|')alternate\1\s*:\s*("|')(?P<url>(?:(?!\2).)*)\2''',
webpage, 'alternate URL', group="url")
test_url = utils.url_or_none(url)
if not test_url:
raise utils.ExtractorError('Invalid audio URL %s' % (url,))
url = test_url
return self.url_result(url=url, video_id=video_id, video_title=title)