This commit is contained in:
@@ -87,6 +87,6 @@ class StreamingRedirectAdmin(ImportExportModelAdmin):
|
||||
(
|
||||
'Information', {
|
||||
"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)
|
||||
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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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))
|
||||
Reference in New Issue
Block a user