mirror of
https://github.com/skoobasteeve/useful-scripts.git
synced 2026-03-20 07:28:57 +00:00
initial working script
This commit is contained in:
72
streaming-check/movie_check.py
Normal file
72
streaming-check/movie_check.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import urllib
|
||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
|
tmdb_api_token = os.environ.get("TMDB_API_TOKEN")
|
||||||
|
sa_api_token = os.environ.get("SA_API_TOKEN")
|
||||||
|
|
||||||
|
tmdb_url = "https://api.themoviedb.org/3"
|
||||||
|
tmdb_headers = {
|
||||||
|
'Authorization': f'Bearer {tmdb_api_token}',
|
||||||
|
'Content-Type': 'application/json;charset=utf-8',
|
||||||
|
'Accept': 'application/json;charset=utf-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
sa_url = "https://streaming-availability.p.rapidapi.com/get/basic"
|
||||||
|
sa_headers = {
|
||||||
|
'x-rapidapi-host': "streaming-availability.p.rapidapi.com",
|
||||||
|
'x-rapidapi-key': sa_api_token
|
||||||
|
}
|
||||||
|
|
||||||
|
movie = "12 angry men"
|
||||||
|
movie_safe = urllib.parse.quote_plus(movie)
|
||||||
|
|
||||||
|
tmdb_search = requests.get(f"{tmdb_url}/search/movie?language=en-US&query={movie_safe}&page=1&include_adult=false", headers=tmdb_headers).json()
|
||||||
|
movie_id = tmdb_search['results'][0]['id']
|
||||||
|
movie_tile = tmdb_search['results'][0]['title']
|
||||||
|
movie_release = tmdb_search['results'][0]['release_date']
|
||||||
|
|
||||||
|
sa_querystring = {"country":"us","tmdb_id":f"movie/{movie_id}","output_language":"en"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sa_response = requests.request("GET", sa_url, headers=sa_headers, params=sa_querystring).json()
|
||||||
|
|
||||||
|
services_list = []
|
||||||
|
services = sa_response["streamingInfo"]
|
||||||
|
|
||||||
|
print(movie_tile + f" ({movie_release})")
|
||||||
|
for s in services:
|
||||||
|
countries = sa_response["streamingInfo"][s]
|
||||||
|
for c in countries:
|
||||||
|
leaving_epoch = sa_response["streamingInfo"][s][c]["leaving"]
|
||||||
|
leaving_date = datetime.fromtimestamp(int(leaving_epoch)).strftime('%Y-%m-%d')
|
||||||
|
link = sa_response["streamingInfo"][s][c]["link"]
|
||||||
|
print(f"Available on {s}")
|
||||||
|
if leaving_epoch != 0:
|
||||||
|
print(f"Will be leaving {s} on {leaving_date}")
|
||||||
|
print(f"Watch here: {link}")
|
||||||
|
# country = response["streamingInfo"][services]
|
||||||
|
# leaving = response["streamingInfo"][services]["leaving"]
|
||||||
|
# link = response["streamingInfo"][services]["link"]
|
||||||
|
|
||||||
|
#print(services)
|
||||||
|
|
||||||
|
|
||||||
|
# changes = {}
|
||||||
|
# for x in services:
|
||||||
|
# changes[x] = response["streamingInfo"][x][x]['leaving']
|
||||||
|
# print(changes)
|
||||||
|
|
||||||
|
|
||||||
|
# for s in services:
|
||||||
|
# services_list.append(s)
|
||||||
|
|
||||||
|
# print(services_list)
|
||||||
|
|
||||||
|
# for s in services['hulu']:
|
||||||
|
# print(s)
|
||||||
|
#print(json.dumps(response, indent=4, sort_keys=True))
|
||||||
Reference in New Issue
Block a user