Skip to content

Commit

Permalink
douyu m3u8
Browse files Browse the repository at this point in the history
  • Loading branch information
i7az committed Sep 21, 2022
1 parent 5d63026 commit 4e8bffd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions douyu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import hashlib
import re
import time

import json
import execjs
import requests

Expand Down Expand Up @@ -79,13 +79,13 @@ def get_js(self):

js = execjs.compile(func_sign)
params = js.call('sign', self.rid, self.did, self.t10)
params += '&ver=219032101&rid={}&rate=-1'.format(self.rid)
params += '&ver=219032101&rid={}&rate=0'.format(self.rid)

url = 'https://m.douyu.com/api/room/ratestream'
res = self.s.post(url, params=params).text
key = re.search(r'(\d{1,8}[0-9a-zA-Z]+)_?\d{0,4}(.m3u8|/playlist)', res).group(1)

return key
return res

def get_pc_js(self, cdn='ws-h5', rate=0):
"""
Expand Down Expand Up @@ -135,3 +135,6 @@ def get_real_url(self):
r = input('输入斗鱼直播间号:\n')
s = DouYu(r)
print(s.get_real_url())
print(json.loads(s.get_js()))
print(s.get_pc_js())

0 comments on commit 4e8bffd

Please sign in to comment.