2 Commits
Author SHA1 Message Date
pierre geeraert f1ffa5c949 rewriting url and adding new one if they were not created
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
2026-07-04 13:11:06 +01:00
pierre geeraert 4d5f3809d9 we can get info from show now 2026-07-04 13:09:01 +01:00
2 changed files with 67 additions and 1 deletions
+19
View File
@@ -104,3 +104,22 @@ class betaserieUtils():
print(response.text)
return response.status_code
def series_information(self,show_id,verbose=False):
#
# Usage
#
url = "https://api.betaseries.com/shows/display?id="+str(show_id)
response = requests.request("GET", url, headers=self.headers, data=self.payload)
maximum_number_seasons = response.json()['show']['seasons']
if verbose : print("maximum_number_seasons: "+str(maximum_number_seasons))
seasons_details = response.json()['show']['seasons_details']
if verbose:
print("Url request: "+str(url))
print(response.text)
return seasons_details,maximum_number_seasons
+48 -1
View File
@@ -1,7 +1,8 @@
from apps.betaserie.utils import betaserieUtils
from django.db.models import Count
from django.core.exceptions import MultipleObjectsReturned
from celery.worker.state import active_requests
from requests.compat import str
from apps.betaserie.utils import betaserieUtils
from .models import simpsons_data_object
betaserie = betaserieUtils()
@@ -35,3 +36,49 @@ def unwatch_all_episodes():
for episode in range(1,maximum_number_of_episodes+1):
print("S"+str(season)+"E"+str(episode))
mark_episode_watched(season,episode,"unwatched")
def generate_new_urls_for_episode(verbose=False):
# kisscartoons didn't work anymore so moving to another website with the format:
# URL.com/simpsons/season=XX&episode=XX
# example
# https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=33&episode=18
simpsons_series_information = betaserie.series_information(simpsons_id)
seasons_information = simpsons_series_information[0]
#for the simpsons, there is a season 0 which increase the count of seasons by 1
# we need to remove this entry ,
# so we cannot trust the maximum_number_season coming from simpsons_series_information
season_0_to_remove = seasons_information[0]
if verbose : print(season_0_to_remove)
seasons_information.remove(season_0_to_remove)
maximum_number_season = len(seasons_information)
for season in range(1,maximum_number_season+1):
# the list doesn't start with season 0 anymore so we cannot use the season number as index
# we need to add -1
number_episodes_in_season = int(seasons_information[season-1]['episodes'])
for episode in range(1,number_episodes_in_season+1):
if verbose : print("Season: "+str(season))
if verbose : print("episode: "+str(episode))
new_url = "https://www.1shows.org/tv/456-the-simpsons?streaming=true&season="+str(season)+"&episode="+str(episode)
if verbose : print(new_url)
try:
obj,created = simpsons_data_object.get_or_create(
season=season,
episode=episode,
defaults={"url":new_url,"seen":"False"}
)
obj.url=new_url
obj.save()
except MultipleObjectsReturned:
print("duplicated object for season: "+str(episode)+" episode: "+str(episode)+", ignoring")
return 0