Testing #30
@@ -113,10 +113,20 @@ class betaserieUtils():
|
|||||||
url = "https://api.betaseries.com/shows/display?id="+str(show_id)
|
url = "https://api.betaseries.com/shows/display?id="+str(show_id)
|
||||||
response = requests.request("GET", url, headers=self.headers, data=self.payload)
|
response = requests.request("GET", url, headers=self.headers, data=self.payload)
|
||||||
|
|
||||||
maximum_number_seasons = response.json()['show']['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("maximum_number_seasons: "+str(maximum_number_seasons))
|
||||||
|
|
||||||
seasons_details = response.json()['show']['seasons_details']
|
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Url request: "+str(url))
|
print("Url request: "+str(url))
|
||||||
|
|||||||
@@ -50,19 +50,15 @@ def generate_new_urls_for_episode(verbose=False):
|
|||||||
# example
|
# example
|
||||||
# https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=33&episode=18
|
# https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=33&episode=18
|
||||||
|
|
||||||
simpsons_series_information = betaserie.series_information(simpsons_id)
|
seasons_information,maximum_number_season = 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
|
#for the simpsons, there is a season 0 which increase the count of seasons by 1
|
||||||
# we need to remove this entry ,
|
# we need to remove this entry ,
|
||||||
# so we cannot trust the maximum_number_season coming from simpsons_series_information
|
# so we cannot trust the maximum_number_season coming from simpsons_series_information
|
||||||
|
|
||||||
season_0_to_remove = seasons_information[0]
|
# edit 26/08/2026
|
||||||
|
# I updated the function betaserie.series_information to remove this season 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):
|
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
|
# the list doesn't start with season 0 anymore so we cannot use the season number as index
|
||||||
|
|||||||
@@ -87,6 +87,6 @@ class StreamingRedirectAdmin(ImportExportModelAdmin):
|
|||||||
(
|
(
|
||||||
'Information', {
|
'Information', {
|
||||||
"classes": ["collapse"],
|
"classes": ["collapse"],
|
||||||
'fields': ('seasonInformation','alias','betaserieShowId')
|
'fields': ('seasonInformation','alias','betaserieShowId','maximumNumberSeason')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
+18
@@ -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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -28,6 +28,7 @@ class StreamingRedirectData(models.Model):
|
|||||||
alias = models.CharField(max_length=1000, null=True,blank=True)
|
alias = models.CharField(max_length=1000, null=True,blank=True)
|
||||||
seasonInformation = models.JSONField(default=dict, blank=True)
|
seasonInformation = models.JSONField(default=dict, blank=True)
|
||||||
betaserieShowId = models.IntegerField(null=True,blank=True)
|
betaserieShowId = models.IntegerField(null=True,blank=True)
|
||||||
|
maximumNumberSeason = models.IntegerField(null=True,blank=True)
|
||||||
randomViewing = models.BooleanField(default=False)
|
randomViewing = models.BooleanField(default=False)
|
||||||
|
|
||||||
def sanitize(self, name):
|
def sanitize(self, name):
|
||||||
@@ -39,6 +40,12 @@ class StreamingRedirectData(models.Model):
|
|||||||
print(betaserie.identify_serie(serie_name))
|
print(betaserie.identify_serie(serie_name))
|
||||||
return betaserie.series_information(betaserie.identify_serie(serie_name))[0]
|
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):
|
def betaserie_show_id(self,serie_name):
|
||||||
betaserie = betaserieUtils()
|
betaserie = betaserieUtils()
|
||||||
print(serie_name)
|
print(serie_name)
|
||||||
@@ -46,6 +53,7 @@ class StreamingRedirectData(models.Model):
|
|||||||
return betaserie.identify_serie(serie_name)
|
return betaserie.identify_serie(serie_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.seasonInformation :
|
if not self.seasonInformation :
|
||||||
self.seasonInformation = self.season_information(self.name)
|
self.seasonInformation = self.season_information(self.name)
|
||||||
@@ -53,6 +61,8 @@ class StreamingRedirectData(models.Model):
|
|||||||
self.alias = self.sanitize(self.name)
|
self.alias = self.sanitize(self.name)
|
||||||
if not self.betaserieShowId:
|
if not self.betaserieShowId:
|
||||||
self.betaserieShowId = self.betaserie_show_id(self.name)
|
self.betaserieShowId = self.betaserie_show_id(self.name)
|
||||||
|
if not self.maximumNumberSeason:
|
||||||
|
self.maximumNumberSeason = self.maximum_Number_Season(self.name)
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ def test_website(url_website,bool_proxy=False):
|
|||||||
def randomEpisode(seasonInformation):
|
def randomEpisode(seasonInformation):
|
||||||
return 0,0
|
return 0,0
|
||||||
|
|
||||||
def followingEpisode(season,episode,seasonInformation):
|
def followingEpisode(season,episode,seasonInformation,maximum_number_seasons):
|
||||||
lastEpisode = False
|
lastEpisode = False
|
||||||
#check if the episode is the last one of the season
|
#check if the episode is the last one of the season
|
||||||
if (episode < seasonInformation[season]['episodes']):
|
if (episode < seasonInformation[season-1]['episodes']):
|
||||||
#the current episode is not the
|
#the current episode is not the last one of the season
|
||||||
episode += 1
|
episode += 1
|
||||||
|
|
||||||
#check if the season is the last one
|
#check if the season is the last one
|
||||||
elif((season+1) < (len(seasonInformation)-1)):
|
elif((season+1) < maximum_number_seasons):
|
||||||
season += 1
|
season += 1
|
||||||
episode = 1
|
episode = 1
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ def streamingRedirect(request,alias):
|
|||||||
episode = streaming_object.values('episode')[0]['episode']
|
episode = streaming_object.values('episode')[0]['episode']
|
||||||
season = streaming_object.values('season')[0]['season']
|
season = streaming_object.values('season')[0]['season']
|
||||||
seasonInformation = streaming_object.values('seasonInformation')[0]['seasonInformation']
|
seasonInformation = streaming_object.values('seasonInformation')[0]['seasonInformation']
|
||||||
|
maximumNumberSeason = streaming_object.values('maximumNumberSeason')[0]['maximumNumberSeason']
|
||||||
|
|
||||||
|
|
||||||
url_prefix = streaming_object.values('prefix')[0]['prefix']
|
url_prefix = streaming_object.values('prefix')[0]['prefix']
|
||||||
url_infix = streaming_object.values('infix')[0]['infix']
|
url_infix = streaming_object.values('infix')[0]['infix']
|
||||||
@@ -48,7 +50,7 @@ def streamingRedirect(request,alias):
|
|||||||
season,episode = randomEpisode()
|
season,episode = randomEpisode()
|
||||||
else:
|
else:
|
||||||
print('show set to following episode')
|
print('show set to following episode')
|
||||||
season,episode,lastEpisode = followingEpisode(season,episode,seasonInformation)
|
season,episode,lastEpisode = followingEpisode(season,episode,seasonInformation,maximumNumberSeason)
|
||||||
if (lastEpisode):
|
if (lastEpisode):
|
||||||
return HttpResponse('<h1>You already watched the last episode of the serie!</h1>')
|
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)
|
betaserie.mark_episodes_watched(episode_id)
|
||||||
|
|
||||||
|
return HttpResponse(str(url_generated))
|
||||||
return redirect(str(url_generated))
|
#return redirect(str(url_generated))
|
||||||
Reference in New Issue
Block a user