Skip to content

Commit

Permalink
增加一点功能
Browse files Browse the repository at this point in the history
  • Loading branch information
239144498 committed Oct 4, 2022
1 parent 4d7cf11 commit 787c59e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
40 changes: 32 additions & 8 deletions app/common/endecrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import json

from base64 import b64decode, b64encode

import requests
from Crypto.Util.Padding import pad, unpad
from Crypto.Cipher import AES

from app.modules.request import request
from app.settings import key, iv, HD, data3
from app.settings import key, iv, HD, data3, edata


def decrypt(info):
Expand All @@ -24,12 +26,7 @@ def decrypt(info):


def encrypt(fs4GTV_ID, fnID):
raw = {"fnCHANNEL_ID": fnID, "fsASSET_ID": fs4GTV_ID, "fsDEVICE_TYPE": "pc",
"clsIDENTITY_VALIDATE_ARUS": {"fsVALUE": ""}}
cipher = AES.new(key, AES.MODE_CBC, iv)
plaintext = bytes(json.dumps(raw), 'utf-8')
ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))
value = b64encode(ciphertext).decode('utf-8')
value = edata[fs4GTV_ID]
headers = {
"Content-Type": "application/json",
"Accept": "application/json, text/plain, */*",
Expand All @@ -42,11 +39,37 @@ def encrypt(fs4GTV_ID, fnID):
return res.json()


def decrypt2(info):
true = True
false =False
null = None
with requests.post(url=data3['a3'], json={"Data": info["Data"]}) as res:
info = eval(json.loads(res.content.decode("utf-8")))
link = info["flstURLs"][1]
return link


def encrypt2(fs4GTV_ID, fnID):
headers = {
"Content-Type": "application/json",
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
}
url = data3['a2']
value = edata[fs4GTV_ID]
data = {'value': value}
with request.post(url=url, json=data, headers=headers) as res:
return res.json()


def get4gtvurl(fs4GTV_ID, fnID, hd):
if key and iv: # 需要特定地区ip请求接口会报错
info = encrypt(fs4GTV_ID, fnID)
link = decrypt(info)
else:
elif "http" in data3['a3']:
info = encrypt2(fs4GTV_ID, fnID)
link = decrypt2(info)
elif "http" in data3['a1']:
url = data3['a1'] + "?vid={}&nid={}&fid={}".format(fs4GTV_ID, fnID, fs4GTV_ID)
with request.get(url=url) as res:
if res.status_code != 200 and 310 - res.status_code > 10:
Expand All @@ -59,3 +82,4 @@ def get4gtvurl(fs4GTV_ID, fnID, hd):
if __name__ == '__main__':
a = get4gtvurl("4gtv-4gtv018", 11, 720)
print(a)

3 changes: 2 additions & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"}).content)
gdata = eval(request.get("https://agit.ai/239144498/owner/raw/branch/master/data2",
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"}).content)

edata = eval(request.get("https://agit.ai/239144498/owner/raw/branch/master/data4",
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"}).content)
HD = {
"360": "stream0.m3u8", "480": "stream1.m3u8", "720": "stream2.m3u8", "1080": "stream2.m3u8",
}
Expand Down
3 changes: 1 addition & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
# @Software: Streaming-Media-Server-Pro
import uvicorn
from threading import Thread
from app.settings import PORT, localhost
from app.settings import PORT
from app.routers import app
from app.utile import everyday


if __name__ == '__main__':
Thread(target=everyday, args=(2,)).start()
print(localhost)
uvicorn.run(app, host="0.0.0.0", port=PORT, log_level="info") # reload=True, debug=True
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ PyMySQL==1.0.2
redis==4.3.4
requests==2.28.1
uvicorn==0.18.3
starlette==0.19.1
# psycopg2-binary

0 comments on commit 787c59e

Please sign in to comment.