I would like to put a disclaimer that I created the software but it might not be ethical or legal. Nonetheless, it can be used in more useful ways potentially so I thought why not release the code.
A question to bring up, would it be wrong if the movie wasn't found anywhere else??
Origin
A while back we had a lot of movies on a bookshelf and I was wondering, what happens if I were to put all of those on a USB. Not only would we save space but also I could play on my laptop which to read from I had to attach an external reader which was very bulky. It was a spontaneous thought and kind of stupid because I know people once they have the hard copy, a web copy doesn't mean you can throw out the original. Nonetheless, I started ripping the movies using a portable DVD reader and timer to set the time to switch out the movie. After a while, we were at 40 GB and had to start hard drive mode. I had about a terabyte when I stopped ripping and agreed on the rest of the movies I would never watch.
Fast forward to earlier this year I ran out of space on hard drives. I needed to do something and at first, I thought compression would work... Well, it didn't and so I tried to upload the videos, too many. Finally, I was like fine, I guess I will just search and if they appear I can delete and if not I will keep them, which cut down 1 TB to 10 GB or so with 50GB of my favorite movies.
Overview
The program will take in the user input and output the result based on API to return if the movie is found/available.
Step by Step
So I start out by using the code below to grab all the movies on one selected website. I chose this website specifically because it already had an API developed.
import requestsimport jsonimport timeclassmovie: links = []def__init__(self,name,Id): self.name = name self.Id = IdbaseUrl ="https://yts.mx/api/v2/"baseInfo = requests.get(baseUrl +"list_movies.json")movieCount = baseInfo.json()['data']['movie_count'] # Total MoviespageLimit =25# Number of results per pagepageNumb =int(movieCount / pageLimit)+1# Number of total pagesidList = []titleList = []defgetPage(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 inrange(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 inrange(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)defmain(): a =open("log.txt", "a")for i inrange(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 inrange(0, len(idList)): f.write(str(idList[i]) +", "+str(titleList[i]) +"\n") f.flush() f.close()main()
This is only step one as the output of this code was
34326, Cooking Up Love (2021)
34311, Robopocalypse (2021)
34307, Disencumber (2021)
34305, Open (2021)
34306, Scavengers (2021)
34303, Reloaded (2021)
34304, R.E.G.I.N.A. I Am (2020)
34302, Like Love (2020)
34326, Cooking Up Love (2021)
34311, Robopocalypse (2021)
34307, Disencumber (2021)
34305, Open (2021)
34306, Scavengers (2021)
34303, Reloaded (2021)
34304, R.E.G.I.N.A. I Am (2020)
34302, Like Love (2020)
...
...
21, 2 Fast 2 Furious (2003)
20, 1984 (1984)
19, 1969 (1988)
18, 1941 (1979)
17, 1776 (1972)
16, 17 Again (2009)
15, 16 Blocks (2006)
14, 1408 (2007)
13, 13/13/13 (2013)
12, 13 Sins (2014)
11, 13 Eerie (2013)
10, 13 (2010)
But this is a good start. I got all the movies and ID extracted from the JSON file.
The next step is to add other parts of the JSON onto the movie object so we can do more functions
For reference below is one return movie result.
{"status":"ok","status_message":"Query was successful", data": { "movie_count": 33683, "limit": 20, "page_number": 1, "movies": [ { "id": 34324, "url": "https://yts.mx/movies/affittasi-vita-2019","imdb_code": "tt10224714","title":"Affittasi Vita","title_english":"Affittasi Vita","title_long":"Affittasi Vita (2019)","slug":"affittasi-vita-2019","year":2019,"rating":5,"runtime":90,"genres": ["Comedy" ], "summary": "The Italian Painter Michele is forced by his rich girlfriend to move to a new house in Trieste, abandoning his privileged life. He finds himself in a new world full of extravagant neighbors and unusual situations that will eventually change his values and prospective of life.",
"description_full": "The Italian Painter Michele is forced by his rich girlfriend to move to a new house in Trieste, abandoning his privileged life. He finds himself in a new world full of extravagant neighbors and unusual situations that will eventually change his values and prospective of life.",
"synopsis": "The Italian Painter Michele is forced by his rich girlfriend to move to a new house in Trieste, abandoning his privileged life. He finds himself in a new world full of extravagant neighbors and unusual situations that will eventually change his values and prospective of life.",
"yt_trailer_code":"","language":"it","mpa_rating":"","background_image":"https://yts.mx/assets/images/movies/affittasi_vita_2019/background.jpg","background_image_original":"https://yts.mx/assets/images/movies/affittasi_vita_2019/background.jpg","small_cover_image":"https://yts.mx/assets/images/movies/affittasi_vita_2019/small-cover.jpg","medium_cover_image":"https://yts.mx/assets/images/movies/affittasi_vita_2019/medium-cover.jpg","large_cover_image":"https://yts.mx/assets/images/movies/affittasi_vita_2019/large-cover.jpg","state":"ok","torrents": [ {"url":"https://yts.mx/torrent/download/1112EAD9263D401A9359849250C82E8C7949AAAB","hash":"1112EAD9263D401A9359849250C82E8C7949AAAB","quality":"720p","type":"web","seeds":0,"peers":0,"size":"837.79 MB","size_bytes":878486487,"date_uploaded":"2021-07-27 20:14:14","date_uploaded_unix":1627409654 }, {"url":"https://yts.mx/torrent/download/5D297E7F6F5F75D993825A80AD753853C1B35E75","hash":"5D297E7F6F5F75D993825A80AD753853C1B35E75","quality":"1080p","type":"web","seeds":0,"peers":0,"size":"1.52 GB","size_bytes":1632087572,"date_uploaded":"2021-07-27 22:18:48","date_uploaded_unix":1627417128 } ],"date_uploaded":"2021-07-27 20:14:14","date_uploaded_unix":1627409654 }, {}] }}
Also want to autocorrect since we have some issues sometimes.
Then also there is what language detection or files are in the download