1 Star 0 Fork 0

果冻/real-url

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
maoer.py 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
wbt5 提交于 2021-05-01 19:15 . :sparkles:Add 猫耳FM (#138)
# -*- coding: utf-8 -*-
# @Time: 2021/5/1 13:03
# @Project: real-url
# @Author: wbt5
# @Blog: https://wbt5.com
import json
import requests
class MAOER:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
'like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 '
}
url = 'https://fm.missevan.com/api/v2/live/{}'.format(self.rid)
with requests.Session() as s:
res = s.get(url, headers=headers).json()
try:
code = res['code']
if code != 0:
return res['info']
else:
channel = res['info']['room']['channel']
return channel
except json.decoder.JSONDecodeError:
return '输入错误'
def get_real_url(rid):
try:
mr = MAOER(rid)
return mr.get_real_url()
except Exception as e:
print('Exception:', e)
return False
if __name__ == '__main__':
r = input('请输入猫耳直播房间号:\n')
print(get_real_url(r))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jelly27/real-url.git
git@gitee.com:jelly27/real-url.git
jelly27
real-url
real-url
master

搜索帮助