Merge branch 'ref'
This commit is contained in:
		
						commit
						b4a68ae793
					
				
							
								
								
									
										21
									
								
								api.py
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								api.py
									
									
									
									
									
								
							@ -67,27 +67,28 @@ class Api():
 | 
				
			|||||||
		return self.stream_url
 | 
							return self.stream_url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def login(self):
 | 
						def login(self):
 | 
				
			||||||
		login = requests.get('https://www.vvvvid.it/user/login', headers={'User-Agent': Api.ua})
 | 
							login = requests.get('https://www.vvvvid.it/user/login', headers={'User-Agent': Api.ua}).json()
 | 
				
			||||||
		self.conn_id = login.json()['data']['conn_id']
 | 
							self.conn_id = login['data']['conn_id']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def get_info(self, show_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 = 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'
 | 
							info.encoding = 'utf-8'
 | 
				
			||||||
		if info.json()['result'] == 'ok':
 | 
							info = info.json()
 | 
				
			||||||
			return info.json()['data']
 | 
							if info['result'] == 'ok':
 | 
				
			||||||
 | 
								return info['data']
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			return False
 | 
								return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def get_seasons(self, show_id):
 | 
						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})
 | 
							seasons = requests.get('https://www.vvvvid.it/vvvvid/ondemand/' + str(show_id) + '/seasons/?conn_id=' + self.conn_id, headers={'User-Agent': Api.ua}).json()
 | 
				
			||||||
		if seasons.json()['result'] == 'ok' and seasons.json()['data'] and seasons.json()['data'][0]['episodes']:
 | 
							if seasons['result'] == 'ok' and seasons['data']:  # and seasons['data'][0]['episodes']:
 | 
				
			||||||
			return seasons.json()['data']
 | 
								return seasons['data']
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			return []
 | 
								return []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def get_episodes(self, season_id, show_id):
 | 
						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()
 | 
							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']:
 | 
							if episodes['result'] == 'ok' and episodes['data']:  # and episodes['data'][0]['embed_info']:
 | 
				
			||||||
			return episodes['data']
 | 
								return episodes['data']
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			return []
 | 
								return []
 | 
				
			||||||
@ -97,7 +98,7 @@ class Api():
 | 
				
			|||||||
		count = 0
 | 
							count = 0
 | 
				
			||||||
		for k in episodes:
 | 
							for k in episodes:
 | 
				
			||||||
			count += 1
 | 
								count += 1
 | 
				
			||||||
			if k['embed_info']:
 | 
								if k.get('embed_info'):
 | 
				
			||||||
				if k['video_type'] == 'video/rcs':
 | 
									if k['video_type'] == 'video/rcs':
 | 
				
			||||||
					embed_info = self.ds(k['embed_info'])
 | 
										embed_info = self.ds(k['embed_info'])
 | 
				
			||||||
					embed_info = 'https' + embed_info[4:30] + 'i' + embed_info[31:-12] + 'master.m3u8'
 | 
										embed_info = 'https' + embed_info[4:30] + 'i' + embed_info[31:-12] + 'master.m3u8'
 | 
				
			||||||
@ -109,5 +110,7 @@ class Api():
 | 
				
			|||||||
					embed_info = self.ds(k['embed_info'])
 | 
										embed_info = self.ds(k['embed_info'])
 | 
				
			||||||
				else:
 | 
									else:
 | 
				
			||||||
					embed_info = self.ds(k['embed_info'])
 | 
										embed_info = self.ds(k['embed_info'])
 | 
				
			||||||
 | 
								else:
 | 
				
			||||||
 | 
									embed_info = ""
 | 
				
			||||||
			eps.append((count, show_id, season_id, k['video_type'], embed_info))
 | 
								eps.append((count, show_id, season_id, k['video_type'], embed_info))
 | 
				
			||||||
		return eps
 | 
							return eps
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								db.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								db.py
									
									
									
									
									
								
							@ -34,7 +34,7 @@ class VVVVIDatabase():
 | 
				
			|||||||
		con.close()
 | 
							con.close()
 | 
				
			||||||
		# getting series in a useful format for later
 | 
							# getting series in a useful format for later
 | 
				
			||||||
		series = {}
 | 
							series = {}
 | 
				
			||||||
		for i,s in rows:
 | 
							for i, s in rows:
 | 
				
			||||||
			if series.get(i) is None:
 | 
								if series.get(i) is None:
 | 
				
			||||||
				series[i] = []
 | 
									series[i] = []
 | 
				
			||||||
			series[i].append(s)
 | 
								series[i].append(s)
 | 
				
			||||||
@ -49,13 +49,12 @@ class VVVVIDatabase():
 | 
				
			|||||||
		con.close()
 | 
							con.close()
 | 
				
			||||||
		# getting series in a useful format for later
 | 
							# getting series in a useful format for later
 | 
				
			||||||
		series = {}
 | 
							series = {}
 | 
				
			||||||
		for i,s in rows:
 | 
							for i, s in rows:
 | 
				
			||||||
			if series.get(i) is None:
 | 
								if series.get(i) is None:
 | 
				
			||||||
				series[i] = []
 | 
									series[i] = []
 | 
				
			||||||
			series[i].append(s)
 | 
								series[i].append(s)
 | 
				
			||||||
		return series
 | 
							return series
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	def insert_serie(self, serie):
 | 
						def insert_serie(self, serie):
 | 
				
			||||||
		con = sqlite3.connect(self.path)
 | 
							con = sqlite3.connect(self.path)
 | 
				
			||||||
		cur = con.cursor()
 | 
							cur = con.cursor()
 | 
				
			||||||
 | 
				
			|||||||
@ -23,10 +23,10 @@ out.write('''<!DOCTYPE html>
 | 
				
			|||||||
<body>
 | 
					<body>
 | 
				
			||||||
<a href="''' + vvvvidb + '''">Source Database</a><br/><br/>''')
 | 
					<a href="''' + vvvvidb + '''">Source Database</a><br/><br/>''')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# select all the series
 | 
					# Select all the series
 | 
				
			||||||
# cur.execute("SELECT * FROM series;")
 | 
					# cur.execute("SELECT * FROM series;")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# selecy only series with at least one episodes
 | 
					# Selecy only series with at least one episodes
 | 
				
			||||||
cur.execute("SELECT s.* FROM series as s INNER JOIN episodes as e ON e.serie_id = s.id AND e.season_id = s.season_id GROUP BY s.id, s.season_id;")
 | 
					cur.execute("SELECT s.* FROM series as s INNER JOIN episodes as e ON e.serie_id = s.id AND e.season_id = s.season_id GROUP BY s.id, s.season_id;")
 | 
				
			||||||
series = cur.fetchall()
 | 
					series = cur.fetchall()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -34,7 +34,7 @@ for s in series:
 | 
				
			|||||||
    serie = (str(s[0]), str(s[2]))
 | 
					    serie = (str(s[0]), str(s[2]))
 | 
				
			||||||
    out.write("\t<h3>{}: {} - Id Serie: {} - Tipo: {}</h3>\n\t<ul>\n".format(s[0], s[1], s[2], s[3]))
 | 
					    out.write("\t<h3>{}: {} - Id Serie: {} - Tipo: {}</h3>\n\t<ul>\n".format(s[0], s[1], s[2], s[3]))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cur.execute("SELECT e.cdn_url FROM episodes AS e JOIN series AS s ON e.serie_id = s.id AND e.season_id = s.season_id WHERE s.id = ? AND s.season_id = ?;", serie)
 | 
					    cur.execute("SELECT e.cdn_url FROM episodes AS e JOIN series AS s ON e.serie_id = s.id AND e.season_id = s.season_id WHERE s.id = ? AND s.season_id = ? AND e.cdn_url != '';", serie)
 | 
				
			||||||
    episodes = cur.fetchall()
 | 
					    episodes = cur.fetchall()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [out.write("\t\t<li><a href=\"player.html#{0}\">{0}</a></li>\n".format(e[0])) for e in episodes]
 | 
					    [out.write("\t\t<li><a href=\"player.html#{0}\">{0}</a></li>\n".format(e[0])) for e in episodes]
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										43
									
								
								vvvvget.py
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								vvvvget.py
									
									
									
									
									
								
							@ -1,7 +1,3 @@
 | 
				
			|||||||
import os
 | 
					 | 
				
			||||||
import json
 | 
					 | 
				
			||||||
import requests
 | 
					 | 
				
			||||||
import sqlite3
 | 
					 | 
				
			||||||
from db import VVVVIDatabase
 | 
					from db import VVVVIDatabase
 | 
				
			||||||
from api import Api
 | 
					from api import Api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -13,6 +9,8 @@ if stream_url is None:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
vvvvidb = VVVVIDatabase("vvvvidb.sqlite3")
 | 
					vvvvidb = VVVVIDatabase("vvvvidb.sqlite3")
 | 
				
			||||||
api.login()
 | 
					api.login()
 | 
				
			||||||
 | 
					last = 0
 | 
				
			||||||
 | 
					smax = 1000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if not vvvvidb.is_valid:
 | 
					if not vvvvidb.is_valid:
 | 
				
			||||||
	# Database file not present
 | 
						# Database file not present
 | 
				
			||||||
@ -24,65 +22,44 @@ else:
 | 
				
			|||||||
	# We scan all the older id to see if there are new episodes, then we scan every id greater then the last one
 | 
						# We scan all the older id to see if there are new episodes, then we scan every id greater then the last one
 | 
				
			||||||
	ids = vvvvidb.series_id()
 | 
						ids = vvvvidb.series_id()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"""
 | 
					 | 
				
			||||||
	for i in ids.keys():
 | 
						for i in ids.keys():
 | 
				
			||||||
		print("Fetching old...{}".format(i))
 | 
							print("Fetching old...{}".format(i))
 | 
				
			||||||
		print(ids.get(i))
 | 
					 | 
				
			||||||
		info = api.get_info(i)
 | 
							info = api.get_info(i)
 | 
				
			||||||
		if not info:
 | 
							if not info:
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		seasons = api.get_seasons(i)
 | 
							seasons = api.get_seasons(i)
 | 
				
			||||||
		for j in seasons:
 | 
							for j in seasons:
 | 
				
			||||||
			serie = (info['show_id'], info['title'], j['season_id'], j['name'])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if j['season_id'] not in ids.get(i):
 | 
								if j['season_id'] not in ids.get(i):
 | 
				
			||||||
				# We found a new season for an old show
 | 
									# We found a new season for an old show
 | 
				
			||||||
				print("Found: {}".format(info['title']))
 | 
									if not vvvvidb.insert_serie((info['show_id'], info['title'], j['season_id'], j['name'])):
 | 
				
			||||||
 | 
					 | 
				
			||||||
				if not vvvvidb.insert_serie(serie):
 | 
					 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				episodes = get_episodes(j['season_id'], i, conn_id)
 | 
								# New episodes for a new or old season
 | 
				
			||||||
				if not episodes:
 | 
								episodes = api.get_episodes(j['season_id'], i)
 | 
				
			||||||
					continue
 | 
								eps = api.format_episodes(j['season_id'], info['show_id'], episodes)
 | 
				
			||||||
				format_episodes(info, j, episodes, vvvvid_stream_url)
 | 
					 | 
				
			||||||
			print("Found {} episodes".format(len(eps)))
 | 
								print("Found {} episodes".format(len(eps)))
 | 
				
			||||||
 | 
					 | 
				
			||||||
				vvvvidb.insert_episode(eps)
 | 
					 | 
				
			||||||
			else:
 | 
					 | 
				
			||||||
				# Check if there are new episodes for old season
 | 
					 | 
				
			||||||
				episodes = get_episodes(j['season_id'], i, conn_id)
 | 
					 | 
				
			||||||
				if not episodes:
 | 
					 | 
				
			||||||
					continue
 | 
					 | 
				
			||||||
				eps = format_episodes(info, j, episodes, vvvvid_stream_url)
 | 
					 | 
				
			||||||
				print("Found {} episodes".format(len(eps)))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			vvvvidb.insert_episodes(eps)
 | 
								vvvvidb.insert_episodes(eps)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		last = i
 | 
							last = i + 1
 | 
				
			||||||
 | 
							smax = 200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	print("Resuming from...{}".format(last))
 | 
						print("Resuming from...{}".format(last))
 | 
				
			||||||
	exit()
 | 
					 | 
				
			||||||
	"""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
last = 0
 | 
					 | 
				
			||||||
# Scan all the episodes
 | 
					# Scan all the episodes
 | 
				
			||||||
for i in range(last, min(last + 500, 1000)):
 | 
					for i in range(last, last + smax):
 | 
				
			||||||
	print("Fetching...{}".format(i))
 | 
						print("Fetching...{}".format(i))
 | 
				
			||||||
	info = api.get_info(i)
 | 
						info = api.get_info(i)
 | 
				
			||||||
	if not info:
 | 
						if not info:
 | 
				
			||||||
		continue
 | 
							continue
 | 
				
			||||||
	seasons = api.get_seasons(i)
 | 
						seasons = api.get_seasons(i)
 | 
				
			||||||
	for j in seasons:
 | 
						for j in seasons:
 | 
				
			||||||
		serie = (info['show_id'], info['title'], j['season_id'], j['name'])
 | 
					 | 
				
			||||||
		print("Found: {}".format(info['title']))
 | 
							print("Found: {}".format(info['title']))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if not vvvvidb.insert_serie(serie):
 | 
							if not vvvvidb.insert_serie((info['show_id'], info['title'], j['season_id'], j['name'])):
 | 
				
			||||||
			print("Serie already present")
 | 
								print("Serie already present")
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		episodes = api.get_episodes(j['season_id'], i)
 | 
							episodes = api.get_episodes(j['season_id'], i)
 | 
				
			||||||
		print(len(episodes))
 | 
					 | 
				
			||||||
		eps = api.format_episodes(j['season_id'], info['show_id'], episodes)
 | 
							eps = api.format_episodes(j['season_id'], info['show_id'], episodes)
 | 
				
			||||||
		print("Found {} episodes".format(len(eps)))
 | 
							print("Found {} episodes".format(len(eps)))
 | 
				
			||||||
		vvvvidb.insert_episodes(eps)
 | 
							vvvvidb.insert_episodes(eps)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user