123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import requests
- class Api():
- ua = "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4.2) Gecko/20020502 CS 2000 7.0/7.0"
- def __init__(self):
- print("Staring VVVVID Api")
- def ds(self, 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(self):
- settings = requests.get('https://www.vvvvid.it/vvvvid/settings', headers={'User-Agent': Api.ua})
- if settings.status_code != 200:
- return None
- self.stream_url = settings.json()['data']['defaultStreamingServer']
- return self.stream_url
- def login(self):
- login = requests.get('https://www.vvvvid.it/user/login', headers={'User-Agent': Api.ua})
- self.conn_id = login.json()['data']['conn_id']
- def get_info(self, show_id):
- info = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/info/?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua})
- info.encoding = 'utf-8'
- if info.json()['result'] == 'ok':
- return info.json()['data']
- else:
- return False
- def get_seasons(self, show_id):
- seasons = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/seasons/?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua})
- if seasons.json()['result'] == 'ok' and seasons.json()['data'] and seasons.json()['data'][0]['episodes']:
- return seasons.json()['data']
- else:
- return []
- def get_episodes(self, season_id, show_id):
- episodes = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/season/' + str(season_id) + '?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua}).json()
- if episodes['result'] == 'ok' and episodes['data'] and episodes['data'][0]['embed_info']:
- return episodes['data']
- else:
- return []
- def format_episodes(self, season_id, show_id, episodes):
- eps = []
- count = 0
- for k in episodes:
- count += 1
- if k['embed_info']:
- if k['video_type'] == 'video/rcs':
- embed_info = self.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' + self.stream_url[4:] + self.ds(k['embed_info']) + '/playlist.m3u8'
- elif k['video_type'] == 'video/youtube':
- embed_info = self.ds(k['embed_info'])
- elif k['video_type'] == 'video/kenc':
- embed_info = self.ds(k['embed_info'])
- else:
- embed_info = self.ds(k['embed_info'])
- eps.append((count, show_id, season_id, k['video_type'], embed_info))
- return eps
|