-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.py
54 lines (46 loc) · 1.56 KB
/
app.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
from flask import Flask, request
from flask_cors import CORS
import requests
import re
app = Flask(__name__)
CORS(app) # This will enable CORS for all routes in your Flask app
pattern = r'\/h\/list'
hostM = 'http://172.232.43.70'
@app.route('/')
def home():
return 'ehhhh'
@app.route('/fetch/')
def fetch():
url = request.args.get('url')
host = request.host
splitedh = host.split(':')
port = splitedh[1]
host = hostM + ':' + port + '/fetch?url='
if url:
match_result = bool(re.search(pattern, url))
url = url.replace(' ', '')
res = requests.get(url, headers={'Referer': 'https://vid30c.site/'})
if url.endswith('.m3u8') and match_result:
text = res.text
main_url = url.split('/list')[0]
splited = text.splitlines()
for index, line in enumerate(splited):
line = line.replace(' ', '')
if line.endswith('.m3u8'):
splited[index] = host + main_url + '/' + line
joined = '\n'.join(splited)
return joined
elif url.endswith('.m3u8') and not match_result:
splited = res.text.splitlines()
for index, line in enumerate(splited):
line = line.replace(' ', '')
if line.startswith('http'):
splited[index] = host + line
joined = '\n'.join(splited)
return joined
else:
return res.content
else:
return 'what the fuck specify url pls '
if __name__ == '__main__':
app.run(debug=True)