Compare commits

..

No commits in common. "8ae863cdb92d42aeb85464bbf6168ba37d9e84df" and "fefbf45f3e2ba1b4a3de63c11b7901a479cd3cf0" have entirely different histories.

View File

@ -1,7 +1,7 @@
import base64
import random
import re
import urllib.parse
import re
from .common import InfoExtractor
from ..utils import (
@ -12,7 +12,6 @@ from ..utils import (
unified_timestamp,
update_url_query,
)
from ..utils.traversal import traverse_obj
class RadikoBaseIE(InfoExtractor):
@ -35,6 +34,8 @@ class RadikoBaseIE(InfoExtractor):
_HOSTS_FOR_LIVE = (
'https://c-radiko.smartstream.ne.jp',
)
# performer separtor character (include Japanese charset)
_PERFORMER_SPLIT_RE = "[//、 ,]"
def _negotiate_token(self):
_, auth1_handle = self._download_webpage_handle(
@ -162,10 +163,7 @@ class RadikoBaseIE(InfoExtractor):
return formats
def _extract_performers(self, prog):
performers = traverse_obj(prog, (
'pfm/text()', ..., {lambda x: re.split(r'[//、 ,]', x)}, ..., {str.strip}))
# TODO: change 'artist' fields to 'artists' and return traversal list instead of str
return ', '.join(performers) or None
return [x.strip() for x in try_call(lambda: re.split(self._PERFORMER_SPLIT_RE, prog.find('pfm').text))]
class RadikoIE(RadikoBaseIE):
@ -194,7 +192,7 @@ class RadikoIE(RadikoBaseIE):
return {
'id': video_id,
'title': try_call(lambda: prog.find('title').text),
'artist': self._extract_performers(prog),
'artists': self._extract_performers(prog),
'description': clean_html(try_call(lambda: prog.find('info').text)),
'uploader': try_call(lambda: station_program.find('.//name').text),
'uploader_id': station,
@ -244,6 +242,7 @@ class RadikoRadioIE(RadikoBaseIE):
title = prog.find('title').text
description = clean_html(prog.find('info').text)
station_name = station_program.find('.//name').text
performers = self._extract_performers(prog)
formats = self._extract_formats(
video_id=station, station=station, is_onair=True,
@ -253,7 +252,7 @@ class RadikoRadioIE(RadikoBaseIE):
return {
'id': station,
'title': title,
'artist': self._extract_performers(prog),
'artists': performers,
'description': description,
'uploader': station_name,
'uploader_id': station,