-
Notifications
You must be signed in to change notification settings - Fork 422
/
egame.py
58 lines (45 loc) · 1.66 KB
/
egame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ykdl.util.html import get_content
from ykdl.util.match import match1
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
import json
class QQEGame(VideoExtractor):
name = u'QQ EGAME (企鹅电竟)'
stream_ids = ['BD8M', 'BD6M', 'BD', 'TD', 'HD', 'SD']
profile_2_id = {
u'蓝光8M': 'BD8M',
u'蓝光6M': 'BD6M',
u'蓝光': 'BD',
u'超清': 'TD',
u'高清': 'HD',
u'流畅': 'SD',
}
def prepare(self):
info = VideoInfo(self.name, True)
if not self.vid:
self.vid = match1(self.url, '/(\d+)')
if not self.url:
self.url = 'https://egame.qq.com/' + self.vid
html = get_content(self.url)
title = match1(html, 'title:"([^"]*)"')
info.artist = artist = match1(html, 'nickName:"([^"]+)"')
info.title = u'{} - {}'.format(title, artist)
playerInfo = match1(html, '_playerInfo = ({.+?});')
self.logger.debug("playerInfo => %s" % (playerInfo))
assert playerInfo, 'error: live show is not on line!!'
playerInfo = json.loads(playerInfo)
for u in playerInfo['urlArray']:
video_profile = u['desc']
stream = self.profile_2_id[video_profile]
info.stream_types.append(stream)
info.streams[stream] = {
'container': 'flv',
'video_profile': video_profile,
'src': [u['playUrl']],
'size': float('inf')
}
info.stream_types = sorted(info.stream_types, key=self.stream_ids.index)
return info
site = QQEGame()