vidsrclinkgen/vidsrclinkgen.py
2022-05-21 02:28:46 +00:00

36 lines
1.2 KiB
Python

try:
import requests
except ImportError:
print("You need to install 'requests'! Open up command prompt, jam in 'pip3 install requests' and hit enter!")
import webbrowser
import time
from requests.exceptions import HTTPError
title = input("Enter the title: ")
type = input("TV or Movie?: ")
typeparsed = ""
# grug brain can't figure out how to read string as capitalized
if type in ["T", "TV", "TV SHOW", "t", "tv", "tv show"]:
typeparsed = "T"
elif type in ["M", "MOVIE", "m", "movie"]:
typeparsed = "M"
if typeparsed == "T":
ep = input("Which episode? SeasonNumber-EpisodeNumber (Example: 2-8)")
try:
response = requests.get('https://www.omdbapi.com/?t=' + title.replace(" ", "+") + '&apikey=e5c6c48f&')
response.raise_for_status()
jsonResponse = response.json()
seriestype = jsonResponse["Type"]
if seriestype == "series":
webbrowser.open('https://vidsrc.me/embed/'+ jsonResponse["imdbID"] + '/' + ep + '/')
elif seriestype == "movie":
webbrowser.open('https://vidsrc.me/embed/'+ jsonResponse["imdbID"] + '/')
except Exception as err:
print("An error has occured! Try typing the title differently!")
time.sleep(10)