new method worked
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
2026-08-26 12:35:43 +01:00
parent 04a216f643
commit 1d86eb582e
7 changed files with 56 additions and 20 deletions
+13 -3
View File
@@ -113,11 +113,21 @@ class betaserieUtils():
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']
#checking if the first season is season 0, and if so remove this season
if (seasons_details[0]['number']==0):
season_0_to_remove = seasons_details[0]
if verbose : print(season_0_to_remove)
seasons_details.remove(season_0_to_remove)
maximum_number_seasons = len(seasons_details)
if verbose : print("maximum_number_seasons: "+str(maximum_number_seasons))
if verbose:
print("Url request: "+str(url))
print(response.text)
+4 -8
View File
@@ -49,20 +49,16 @@ def generate_new_urls_for_episode(verbose=False):
# URL.com/simpsons/season=XX&episode=XX
# example
# https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=33&episode=18
seasons_information,maximum_number_season = betaserie.series_information(simpsons_id)
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)
# edit 26/08/2026
# I updated the function betaserie.series_information to remove this season 0
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
+1 -1
View File
@@ -87,6 +87,6 @@ class StreamingRedirectAdmin(ImportExportModelAdmin):
(
'Information', {
"classes": ["collapse"],
'fields': ('seasonInformation','alias','betaserieShowId')
'fields': ('seasonInformation','alias','betaserieShowId','maximumNumberSeason')
}),
)
@@ -0,0 +1,18 @@
# Generated by Django 4.2.30 on 2026-08-26 11:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('streaming', '0012_alter_streamingredirectdata_betaserieshowid'),
]
operations = [
migrations.AddField(
model_name='streamingredirectdata',
name='maximumNumberSeason',
field=models.IntegerField(blank=True, null=True),
),
]
+11 -1
View File
@@ -28,6 +28,7 @@ class StreamingRedirectData(models.Model):
alias = models.CharField(max_length=1000, null=True,blank=True)
seasonInformation = models.JSONField(default=dict, blank=True)
betaserieShowId = models.IntegerField(null=True,blank=True)
maximumNumberSeason = models.IntegerField(null=True,blank=True)
randomViewing = models.BooleanField(default=False)
def sanitize(self, name):
@@ -38,7 +39,13 @@ class StreamingRedirectData(models.Model):
print(serie_name)
print(betaserie.identify_serie(serie_name))
return betaserie.series_information(betaserie.identify_serie(serie_name))[0]
def maximum_Number_Season(self, serie_name):
betaserie = betaserieUtils()
print(serie_name)
print(betaserie.identify_serie(serie_name))
return betaserie.series_information(betaserie.identify_serie(serie_name))[1]
def betaserie_show_id(self,serie_name):
betaserie = betaserieUtils()
print(serie_name)
@@ -46,6 +53,7 @@ class StreamingRedirectData(models.Model):
return betaserie.identify_serie(serie_name)
def save(self, *args, **kwargs):
if not self.seasonInformation :
self.seasonInformation = self.season_information(self.name)
@@ -53,6 +61,8 @@ class StreamingRedirectData(models.Model):
self.alias = self.sanitize(self.name)
if not self.betaserieShowId:
self.betaserieShowId = self.betaserie_show_id(self.name)
if not self.maximumNumberSeason:
self.maximumNumberSeason = self.maximum_Number_Season(self.name)
super().save(*args, **kwargs)
class Meta:
+4 -4
View File
@@ -41,15 +41,15 @@ def test_website(url_website,bool_proxy=False):
def randomEpisode(seasonInformation):
return 0,0
def followingEpisode(season,episode,seasonInformation):
def followingEpisode(season,episode,seasonInformation,maximum_number_seasons):
lastEpisode = False
#check if the episode is the last one of the season
if (episode < seasonInformation[season]['episodes']):
#the current episode is not the
if (episode < seasonInformation[season-1]['episodes']):
#the current episode is not the last one of the season
episode += 1
#check if the season is the last one
elif((season+1) < (len(seasonInformation)-1)):
elif((season+1) < maximum_number_seasons):
season += 1
episode = 1
else:
+5 -3
View File
@@ -19,6 +19,8 @@ def streamingRedirect(request,alias):
episode = streaming_object.values('episode')[0]['episode']
season = streaming_object.values('season')[0]['season']
seasonInformation = streaming_object.values('seasonInformation')[0]['seasonInformation']
maximumNumberSeason = streaming_object.values('maximumNumberSeason')[0]['maximumNumberSeason']
url_prefix = streaming_object.values('prefix')[0]['prefix']
url_infix = streaming_object.values('infix')[0]['infix']
@@ -48,7 +50,7 @@ def streamingRedirect(request,alias):
season,episode = randomEpisode()
else:
print('show set to following episode')
season,episode,lastEpisode = followingEpisode(season,episode,seasonInformation)
season,episode,lastEpisode = followingEpisode(season,episode,seasonInformation,maximumNumberSeason)
if (lastEpisode):
return HttpResponse('<h1>You already watched the last episode of the serie!</h1>')
@@ -72,5 +74,5 @@ def streamingRedirect(request,alias):
betaserie.mark_episodes_watched(episode_id)
return redirect(str(url_generated))
return HttpResponse(str(url_generated))
#return redirect(str(url_generated))