Online Movie Finder
WARNING WARNING
Origin
Overview
Step by Step
import requests
import json
import time
class movie:
links = []
def __init__(self, name, Id):
self.name = name
self.Id = Id
baseUrl = "https://yts.mx/api/v2/"
baseInfo = requests.get(baseUrl + "list_movies.json")
movieCount = baseInfo.json()['data']['movie_count'] # Total Movies
pageLimit = 25 # Number of results per page
pageNumb = int(movieCount / pageLimit) + 1 # Number of total pages
idList = []
titleList = []
def getPage(page):
requestString = baseUrl + "list_movies.json?limit=" + str(pageLimit) + "&page="+str(page)
# response = requests.get(baseUrl + "list_movies.json?limit=20&page=1")
response = requests.get(requestString)
#print(response.status)
data = response.json()
movies = data['data']['movies']
urls = []
otherInfo = []
for i in range(0, len(movies)):
curId = movies[i]['id']
fullTitle = movies[i]['title_long']
coverImage = movies[i]['background_image']
state = movies[i]['state']
if state == 'ok':
links = movies[i]['torrents']
for o in range(0, len(links)):
temp = links[o]
seed = temp['seeds']
leech = temp['peers']
if seed == 0:
print("The movie " + fullTitle +" is unavailable")
else:
urls.append(temp['url'])
otherInfo.append(temp['quality'] + " " + temp['type'] + " " + temp['size'])
idList.append(curId)
titleList.append(fullTitle)
else:
print("we are not ok")
time.sleep(1)
def main():
a = open("log.txt", "a")
for i in range(0, pageNumb):
try:
getPage(i)
except:
a.write("Screwed up on page "+ str(i) + "\n")
print("Something Screwed up on page " + str(i))
print(idList)
print(titleList)
time.sleep(2)
time.sleep(.5)
print(str(len(idList)) + str(len(titleList)))
input()
f = open("results.txt", "w") # Fix it is writting results twice
for i in range(0, len(idList)):
f.write(str(idList[i]) + ", " + str(titleList[i]) + "\n")
f.flush()
f.close()
main()
Last updated