import requests import hashlib from apps.bitwarden.utils import bitwardenUtils class betaserieUtils(): url = "https://api.betaseries.com/members/auth" token_UID="2cf4be0f-f26f-473f-b8f1-b473016139e4" #Adding __ to make the variable private and can't be access outside the class, # only by the class itself ot the subclass __access_token = "0.7720f24b-4328-41ef-b70b-b419018270a3.nhBoRMSkfrlxqJVZ9W0W1g3lNFrmfI:35muVQz2mO3coR46bIZgcQ==" __organization_id = "a6361589-badd-4bde-9cb4-af8901161c0d" bw = bitwardenUtils(__access_token,__organization_id) __betaserie_token = bw.read_value_secret(token_UID) payload = {} headers = { 'X-BetaSeries-Key': __betaserie_token, 'X-BetaSeries-Token': __betaserie_token } def identify_serie(self,serie_name,verbose=False): # # Usage # show_id = beta.identify_serie("The simpsons") # show_id = beta.identify_serie("The simpsons",verbose=True) # url = "https://api.betaseries.com/shows/search?title="+serie_name response = requests.request("GET", url, headers=self.headers, data=self.payload) if verbose: print("Url request: "+str(url)) print(response.text) show_id = response.json()['shows'][0]['id'] return show_id def identify_episode(self,show_id,episode_number,verbose=False): # # Usage # episode_id = beta.identify_episode(show_id,"S01E01",True) # url = "https://api.betaseries.com/episodes/search?show_id="+str(show_id)+"&number="+str(episode_number) response = requests.request("GET", url, headers=self.headers, data=self.payload) episode_id = response.json()['episode']['id'] if verbose: print("Url request: "+str(url)) print(response.text) return episode_id def mark_episodes_watched(self,episode_id,verbose=False): url = "https://api.betaseries.com/episodes/watched?id=episode_id" response = requests.request("POST", url, headers=self.headers, data=self.payload) if verbose: print("Url request: "+str(url)) print(response.text) print(response.text)