vvvvget/vvvvget.py

139 lines
4.3 KiB
Python
Raw Normal View History

2018-03-27 22:10:39 +02:00
import json
import requests
def ds(h):
g = "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
def f(m):
l = []
o = 0
b = False
m_len = len(m)
while ((not b) and o < m_len):
n = m[o] << 2
o += 1
k = -1
j = -1
if o < m_len:
n += m[o] >> 4
o += 1
if o < m_len:
k = (m[o - 1] << 4) & 255
k += m[o] >> 2
o += 1
if o < m_len:
j = (m[o - 1] << 6) & 255
j += m[o]
o += 1
else:
b = True
else:
b = True
else:
b = True
l.append(n)
if k != -1:
l.append(k)
if j != -1:
l.append(j)
return l
c = []
for e in h:
c.append(g.index(e))
c_len = len(c)
for e in range(c_len * 2 - 1, -1, -1):
a = c[e % c_len] ^ c[(e + 1) % c_len]
c[e % c_len] = a
c = f(c)
d = ''
for e in c:
d += chr(e)
return d
def get_settings():
settings = requests.get('https://www.vvvvid.it/vvvvid/settings')
return settings.json()['data']['defaultStreamingServer']
def login():
login = requests.get('https://www.vvvvid.it/user/login')
return login.json()['data']['conn_id']
def get_info(show_id, conn_id):
info = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/info/?conn_id=' + conn_id)
info.encoding = 'utf-8'
if info.json()['result'] == 'ok':
return info.json()['data']
else:
return False
def get_seasons(show_id, conn_id):
seasons = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/seasons/?conn_id=' + conn_id)
if seasons.json()['result'] == 'ok' and seasons.json()['data'] and seasons.json()['data'][0]['episodes']:
return seasons.json()['data']
else:
return False
def get_episodes(season_id, show_id, conn_id):
episodes = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/season/' +str(season_id) + '?conn_id=' + conn_id)
if episodes.json()['result'] == 'ok' and episodes.json()['data'] and episodes.json()['data'][0]['embed_info']:
return episodes.json()['data']
else:
return False
vvvvid_stream_url = get_settings()
with open('index.html', 'a') as out:
out.write('''<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Anime | lsd.cat</title>
<link rel="icon" sizes="16x16" type="image/png" href="/icon.png" />
<style type="text/css">body{margin:40px auto;max-width:740px;line-height:1.6;color:#444;padding:0 10px}h1,h2,h3{line-height:1.2;font-size:18px;}li{font-size:12px;}</style>
</head>
<body>''')
stream_url = get_settings()
conn_id = login()
for i in range(0,1000):
info = get_info(i, conn_id)
if info:
seasons = get_seasons(i, conn_id)
if seasons:
for j in seasons:
episodes = get_episodes(j['season_id'], i, conn_id)
if episodes:
header = '\t<h3>' + str(info['show_id']) + ': ' + info['title'] + ' Tipo: ' + j['name'] + ' Id: ' + str(j['season_id'])+'</h3>\n\t<ul>\n'
with open('index.html', 'a') as out:
out.write(header.encode('utf-8'))
for k in episodes:
if k['embed_info']:
if k['video_type'] == 'video/rcs':
embed_info = ds(k['embed_info'])
embed_info = 'https' + embed_info[4:30] + 'i' + embed_info[31:-12] + 'master.m3u8'
elif k['video_type'] == 'video/vvvvid':
embed_info = 'https' + vvvvid_stream_url[4:] + ds(k['embed_info']) + '/playlist.m3u8'
elif k['video_type'] == 'video/youtube':
embed_info = ds(k['embed_info'])
elif k['video_type'] == 'video/kenc':
#requires flash, skipping
embed_info = '[FLASH ONLY] ' + ds(k['embed_info'])
else:
print(k['video_type'])
print(ds(k['embed_info']))
print('Unknown video source!')
exit()
with open('index.html', 'a') as out:
out.write('\t\t<li><a href="player.html#' + embed_info + '">' + embed_info + '</a></li>\n')
with open('index.html', 'a') as out:
out.write('\t</ul>\n')
with open('index.html', 'a') as out:
out.write('\n</body>\n</html>')