]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/line.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_str
14 class LineLiveBaseIE(InfoExtractor
):
15 _API_BASE_URL
= 'https://live-api.line-apps.com/web/v4.0/channel/'
17 def _parse_broadcast_item(self
, item
):
18 broadcast_id
= compat_str(item
['id'])
20 is_live
= item
.get('isBroadcastingNow')
23 for thumbnail_id
, thumbnail_url
in (item
.get('thumbnailURLs') or {}).items():
31 channel
= item
.get('channel') or {}
32 channel_id
= str_or_none(channel
.get('id'))
37 'thumbnails': thumbnails
,
38 'timestamp': int_or_none(item
.get('createdAt')),
39 'channel': channel
.get('name'),
40 'channel_id': channel_id
,
41 'channel_url': format_field(channel_id
, template
='https://live.line.me/channels/%s'),
42 'duration': int_or_none(item
.get('archiveDuration')),
43 'view_count': int_or_none(item
.get('viewerCount')),
44 'comment_count': int_or_none(item
.get('chatCount')),
49 class LineLiveIE(LineLiveBaseIE
):
50 _VALID_URL
= r
'https?://live\.line\.me/channels/(?P<channel_id>\d+)/broadcast/(?P<id>\d+)'
52 'url': 'https://live.line.me/channels/5833718/broadcast/18373277',
53 'md5': '2c15843b8cb3acd55009ddcb2db91f7c',
56 'title': '2021/12/05 (15分犬)定例譲渡会🐶',
58 'timestamp': 1638674925,
59 'upload_date': '20211205',
60 'thumbnail': 'md5:e1f5817e60f4a72b7e43377cf308d7ef',
61 'channel_url': 'https://live.line.me/channels/5833718',
62 'channel': 'Yahooニュース掲載🗞プロフ見てね🐕🐕',
63 'channel_id': '5833718',
70 # archiveStatus == 'DELETED'
71 'url': 'https://live.line.me/channels/4778159/broadcast/16378488',
72 'only_matching': True,
75 def _real_extract(self
, url
):
76 channel_id
, broadcast_id
= self
._match
_valid
_url
(url
).groups()
77 broadcast
= self
._download
_json
(
78 self
._API
_BASE
_URL
+ '%s/broadcast/%s' % (channel_id
, broadcast_id
),
80 item
= broadcast
['item']
81 info
= self
._parse
_broadcast
_item
(item
)
82 protocol
= 'm3u8' if info
['is_live'] else 'm3u8_native'
84 for k
, v
in (broadcast
.get(('live' if info
['is_live'] else 'archived') + 'HLSURLs') or {}).items():
88 formats
.extend(self
._extract
_m
3u8_formats
(
89 v
, broadcast_id
, 'mp4', protocol
,
90 m3u8_id
='hls', fatal
=False))
94 'format_id': 'hls-' + k
,
102 archive_status
= item
.get('archiveStatus')
103 if archive_status
!= 'ARCHIVED':
104 self
.raise_no_formats('this video has been ' + archive_status
.lower(), expected
=True)
105 self
._sort
_formats
(formats
)
106 info
['formats'] = formats
110 class LineLiveChannelIE(LineLiveBaseIE
):
111 _VALID_URL
= r
'https?://live\.line\.me/channels/(?P<id>\d+)(?!/broadcast/\d+)(?:[/?&#]|$)'
113 'url': 'https://live.line.me/channels/5893542',
116 'title': 'いくらちゃんだよぉ🦒',
117 'description': 'md5:4d418087973ad081ceb1b3481f0b1816',
119 'playlist_mincount': 29
122 def _archived_broadcasts_entries(self
, archived_broadcasts
, channel_id
):
124 for row
in (archived_broadcasts
.get('rows') or []):
125 share_url
= str_or_none(row
.get('shareURL'))
128 info
= self
._parse
_broadcast
_item
(row
)
132 'ie_key': LineLiveIE
.ie_key(),
135 if not archived_broadcasts
.get('hasNextPage'):
137 archived_broadcasts
= self
._download
_json
(
138 self
._API
_BASE
_URL
+ channel_id
+ '/archived_broadcasts',
140 'lastId': info
['id'],
143 def _real_extract(self
, url
):
144 channel_id
= self
._match
_id
(url
)
145 channel
= self
._download
_json
(self
._API
_BASE
_URL
+ channel_id
, channel_id
)
146 return self
.playlist_result(
147 self
._archived
_broadcasts
_entries
(channel
.get('archivedBroadcasts') or {}, channel_id
),
148 channel_id
, channel
.get('title'), channel
.get('information'))