following episode function good, need to work on the random episode and more admin stuff
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s

This commit is contained in:
2026-08-25 16:24:43 +01:00
parent e66c7034f0
commit e85c372ad8
9 changed files with 193 additions and 8 deletions
+5 -4
View File
@@ -72,20 +72,21 @@ class streamingAdmin(ImportExportModelAdmin):
@admin.register(StreamingRedirectData)
class StreamingRedirectAdmin(ImportExportModelAdmin):
list_display = ['name','season_to_watch','episode_to_watch','randomViewing','url_example','addedDate','alias']
#fields = ['name','season_to_watch','episode_to_watch','url_example','prefix','infix','suffix','alias','randomViewing','seasonInformation']
list_display = ['name','season','episode','randomViewing','url_example','addedDate','alias']
#fields = ['name','season','episode','url_example','prefix','infix','suffix','alias','randomViewing','seasonInformation']
fieldsets = (
(
'Serie', {
'fields': ('name', 'season_to_watch', 'episode_to_watch','randomViewing')
'fields': ('name', 'season', 'episode','randomViewing')
}),
(
'url', {
'fields': (('prefix','infix','suffix'),'url_example')
}),
(
'Information', {
"classes": ["collapse"],
'fields': ('seasonInformation','alias')
'fields': ('seasonInformation','alias','betaserieShowId')
}),
)
@@ -0,0 +1,23 @@
# Generated by Django 4.2.30 on 2026-08-25 14:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('streaming', '0008_streamingredirectdata_randomviewing_and_more'),
]
operations = [
migrations.RenameField(
model_name='streamingredirectdata',
old_name='episode_to_watch',
new_name='episode',
),
migrations.RenameField(
model_name='streamingredirectdata',
old_name='season_to_watch',
new_name='season',
),
]
@@ -0,0 +1,18 @@
# Generated by Django 4.2.30 on 2026-08-25 14:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('streaming', '0009_rename_episode_to_watch_streamingredirectdata_episode_and_more'),
]
operations = [
migrations.AlterField(
model_name='streamingredirectdata',
name='episode',
field=models.IntegerField(default=0),
),
]
@@ -0,0 +1,18 @@
# Generated by Django 4.2.30 on 2026-08-25 15:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('streaming', '0010_alter_streamingredirectdata_episode'),
]
operations = [
migrations.AddField(
model_name='streamingredirectdata',
name='betaserieShowId',
field=models.IntegerField(default=0),
),
]
@@ -0,0 +1,18 @@
# Generated by Django 4.2.30 on 2026-08-25 15:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('streaming', '0011_streamingredirectdata_betaserieshowid'),
]
operations = [
migrations.AlterField(
model_name='streamingredirectdata',
name='betaserieShowId',
field=models.IntegerField(blank=True, null=True),
),
]
+12 -3
View File
@@ -18,8 +18,8 @@ class StreamingSiteTestingData(models.Model):
class StreamingRedirectData(models.Model):
name = models.CharField(primary_key=True,max_length=1000, help_text="Name of the show")
season_to_watch = models.IntegerField(null=False,default=1)
episode_to_watch = models.IntegerField(null=False,default=1)
season = models.IntegerField(null=False,default=1)
episode = models.IntegerField(null=False,default=0)
url_example = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=18&episode=5")
prefix = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=",blank=True, null=True)
infix = models.CharField(max_length=1000, help_text="&episode=",blank=True, null=True)
@@ -27,6 +27,7 @@ class StreamingRedirectData(models.Model):
addedDate = models.DateField('Published', blank=True, null=True, auto_now_add=True)
alias = models.CharField(max_length=1000, null=True,blank=True)
seasonInformation = models.JSONField(default=dict, blank=True)
betaserieShowId = models.IntegerField(null=True,blank=True)
randomViewing = models.BooleanField(default=False)
def sanitize(self, name):
@@ -37,13 +38,21 @@ class StreamingRedirectData(models.Model):
print(serie_name)
print(betaserie.identify_serie(serie_name))
return betaserie.series_information(betaserie.identify_serie(serie_name))[0]
def betaserie_show_id(self,serie_name):
betaserie = betaserieUtils()
print(serie_name)
print(betaserie.identify_serie(serie_name))
return betaserie.identify_serie(serie_name)
def save(self, *args, **kwargs):
if not self.seasonInformation :
self.seasonInformation = self.season_information(self.name)
if not self.alias:
self.alias = self.sanitize(self.name)
if not self.betaserieShowId:
self.betaserieShowId = self.betaserie_show_id(self.name)
super().save(*args, **kwargs)
class Meta:
+19
View File
@@ -37,3 +37,22 @@ def test_website(url_website,bool_proxy=False):
status = "exception not targeted"
return status
def randomEpisode():
return 0,0
def followingEpisode(season,episode,seasonInformation):
lastEpisode = False
#check if the episode is the last one of the season
if (episode < seasonInformation[season]['episodes']):
#the current episode is not the
episode += 1
#check if the season is the last one
elif((season+1) < (len(seasonInformation)-1)):
season += 1
episode = 1
else:
print("You watched the last episode of the serie")
lastEpisode = True
return season,episode,lastEpisode
+74 -1
View File
@@ -1,3 +1,76 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import redirect
from six import print_
from .models import StreamingRedirectData
from .utils import randomEpisode,followingEpisode
from apps.betaserie.utils import betaserieUtils
betaserie = betaserieUtils()
# Create your views here.
def hello(request):
return HttpResponse('<h1>Hello streaming view!</h1>')
def streamingRedirect(request,alias):
streaming_object = StreamingRedirectData.objects.filter(alias=alias)
episode = streaming_object.values('episode')[0]['episode']
season = streaming_object.values('season')[0]['season']
seasonInformation = streaming_object.values('seasonInformation')[0]['seasonInformation']
url_prefix = streaming_object.values('prefix')[0]['prefix']
url_infix = streaming_object.values('infix')[0]['infix']
url_suffix = streaming_object.values('suffix')[0]['suffix'] or ''
betaserieShowId = streaming_object.values('betaserieShowId')[0]['betaserieShowId']
print(url_prefix)
print(season)
print(episode)
print(seasonInformation)
value = str(streaming_object.values('url_example'))
print(value)
url_example = str(streaming_object.values('url_example')[0]['url_example'])
print(url_example)
randomViewing =str(streaming_object.values('randomViewing')[0]['randomViewing'])
print(randomViewing)
if (randomViewing == False):
print('show set to random')
season,episode = randomEpisode()
else:
print('show set to following episode')
season,episode,lastEpisode = followingEpisode(season,episode,seasonInformation)
if (lastEpisode):
return HttpResponse('<h1>You already watched the last episode of the serie!</h1>')
print(season)
print(episode)
url_generated = str(url_prefix)+str(season)+str(url_infix)+str(episode)+str(url_suffix)
print(url_generated)
#append the data into the model
StreamingRedirectData.objects.filter(alias=alias).update(season=season,episode=episode)
#### mark as view in betaserie
#mark episode as seen in betaserie
episode_number = "S"+str(season)+"E"+str(episode)
episode_id = betaserie.identify_episode(betaserieShowId,episode_number)
betaserie.mark_episodes_watched(episode_id)
return redirect(str(url_generated))