找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 1634|回复: 149

[iptv信源 资源分享或寻求] 深圳官网切片代理源码,10个频道

 火.. [复制链接]
本帖最后由 doubebly 于 2024-4-17 15:25 编辑

  1. # -*- coding: utf-8 -*-
  2. # @Author  : Doubebly
  3. # @Time    : 2024/4/17 14:16
  4. # @Function:
  5. """
  6. 深圳卫视,http://127.0.0.1:5000/iptv/1.m3u8
  7. 都市频道,http://127.0.0.1:5000/iptv/2.m3u8
  8. 电视剧频道,http://127.0.0.1:5000/iptv/3.m3u8
  9. 公共频道,http://127.0.0.1:5000/iptv/4.m3u8
  10. 财*频道,http://127.0.0.1:5000/iptv/5.m3u8
  11. 娱乐生活频道,http://127.0.0.1:5000/iptv/6.m3u8
  12. 少儿频道,http://127.0.0.1:5000/iptv/7.m3u8
  13. 移动电视,http://127.0.0.1:5000/iptv/8.m3u8
  14. 宜和购物频道,http://127.0.0.1:5000/iptv/9.m3u8
  15. 国际频道,http://127.0.0.1:5000/iptv/10.m3u8
  16. """
  17. import re
  18. import time
  19. import hashlib
  20. import requests
  21. import urllib3
  22. import base64
  23. from flask import Flask, Response
  24. from flask_cors import CORS

  25. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  26. app = Flask(__name__)
  27. CORS(app)

  28. tv_list = {
  29.     '1': ['AxeFRth', '7867', '深圳卫视'],
  30.     '2': ['ZwxzUXr', '7868', '都市频道'],
  31.     '3': ['4azbkoY', '7880', '电视剧频道'],
  32.     '4': ['2q76Sw2', '7874', '公共频道'],
  33.     '5': ['3vlcoxP', '7871', '财*频道'],
  34.     '6': ['1q4iPng', '7872', '娱乐生活频道'],
  35.     '7': ['1SIQj6s', '7881', '少儿频道'],
  36.     '8': ['wDF6KJ3', '7869', '移动电视'],
  37.     '9': ['BJ5u5k2', '7878', '宜和购物频道'],
  38.     '10': ['sztvgjpd', '7944', '国际频道'],
  39. }


  40. def get_header():
  41.     headers = {
  42.         "Accept": "application/json, text/javascript, */*; q=0.01",
  43.         "Accept-Language": "zh-CN,zh;q=0.9",
  44.         "Cache-Control": "no-cache",
  45.         "Connection": "keep-alive",
  46.         "Origin": "https://www.sztv.com.cn",
  47.         "Pragma": "no-cache",
  48.         "Referer": "https://www.sztv.com.cn/",
  49.         "Sec-Fetch-Dest": "empty",
  50.         "Sec-Fetch-Mode": "cors",
  51.         "Sec-Fetch-Site": "cross-site",
  52.         "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
  53.         "sec-ch-ua-mobile": "?0"
  54.     }
  55.     return headers


  56. def md5(a):
  57.     return hashlib.md5(a.encode()).hexdigest()


  58. def deb64(e):
  59.     return base64.b64decode(e.encode()).decode()


  60. def ba(a):
  61.     b = int(len(a) - len(a) / 2)
  62.     a = a[b:] + a[0:b]
  63.     b = list(a)
  64.     b.reverse()
  65.     return deb64(''.join(b))


  66. def get_live_key(live_id):
  67.     url = 'https://cls2.cutv.com/getCutvHlsLiveKey'
  68.     t = str(int(time.time()))
  69.     params = {
  70.         "t": t,
  71.         "id": live_id,
  72.         "token": md5(t + live_id + 'cutvLiveStream|Dream2017'),
  73.         "at": "1"
  74.     }
  75.     response = requests.get(url, headers=get_header(), params=params)
  76.     # print(response.json())
  77.     return response.json()


  78. def get_cdn_key(e):
  79.     url = 'https://sttv2-api.cutv.com/api/getCDNkey.php'
  80.     t = str(int(time.time() * 1000))
  81.     params = {
  82.         "domain": "sztv-live.cutv.com",
  83.         "page": "https://www.sztv.com.cn/pindao/index.html?id=" + e,
  84.         "token": md5('iYKkRHlmUanQGaNMIJziWOkNsztv-live.cutv.com' + t),
  85.         "t": t
  86.     }
  87.     response = requests.get(url, headers=get_header(), params=params, verify=False)
  88.     return response.json()['key']


  89. def get_m3u8_text(e):
  90.     live_id = tv_list[e][0]
  91.     live_key = ba(get_live_key(live_id))
  92.     t = hex(int(time.time()))[2:]
  93.     key = get_cdn_key(tv_list[e][1])
  94.     sign = md5(f'{key}/{live_id}/500/{live_key}.m3u8{t}')
  95.     url = f'https://sztv-live.cutv.com/{live_id}/500/{live_key}.m3u8?sign={sign}&t={t}'
  96.     response = requests.get(url, headers=get_header())
  97.     m3u8_text = re.sub('(.*.ts.*)', f'/iptv/{live_id}/500/\\1', response.text)
  98.     return m3u8_text


  99. def get_ts(url):
  100.     try:
  101.         res = requests.get('https://sztv-live.cutv.com/' + url, headers=get_header(), timeout=5)
  102.         if res.status_code == 200:
  103.             return res.content
  104.         else:
  105.             return get_ts(url)
  106.     except requests.exceptions.RequestException:
  107.         return get_ts(url)


  108. @app.route('/')
  109. def home():
  110.     return {'StatusCode': 200}


  111. @app.route('/iptv/<path:path>')
  112. def iptv(path):
  113.     if 'm3u8' in path:
  114.         ids = path.split('.')[0]
  115.         filtered_content = get_m3u8_text(ids)
  116.         headers = {
  117.             'Content-Type': 'application/vnd.apple.mpegurl',
  118.             'Access-Control-Allow-Origin': '*',
  119.         }
  120.         # print(filtered_content)
  121.         return Response(filtered_content, headers=headers)
  122.     elif 'ts' in path:
  123.         ts_content = get_ts(path)
  124.         return Response(ts_content, mimetype='video/mp2t')
  125.     else:
  126.         return {'code': 400}


  127. if __name__ == '__main__':
  128.     app.run()
  129.     pass
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
瞧一瞧这位大神写的
回复

使用道具 举报

看看谢谢大佬分享
回复

使用道具 举报

深圳官网切片代理源码,10个频道
回复

使用道具 举报

牛133333333333333333333333333
回复

使用道具 举报

看看怎么样了ij
回复

使用道具 举报

谢谢分享。。。。。。。
回复

使用道具 举报

来自手机 | 显示全部楼层
思考思考,感谢分享
回复

使用道具 举报

多谢楼主分享!
回复

使用道具 举报

谢谢分享!!!
回复

使用道具 举报

看一下谢谢!!!!!!
回复

使用道具 举报

谢谢分享
回复

使用道具 举报

感谢分享~~~
回复

使用道具 举报

瞧一瞧这位大神写的
回复

使用道具 举报

感谢分享         
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-5-15 09:42

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表