Files
Django_kube/django_code/apps/random_simpsons/utils.py
T
pi-ux-ce ad9c6c7a2a
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
adding the unseen all option
2026-06-25 16:01:08 +01:00

38 lines
1.4 KiB
Python

from apps.betaserie.utils import betaserieUtils
from django.db.models import Count
from celery.worker.state import active_requests
from requests.compat import str
from .models import simpsons_data_object
betaserie = betaserieUtils()
simpsons_id = 12
def mark_episode_watched(season,episode,action):
print("season_number: "+str(season))
print("episode_number: "+str(episode))
episode_number = "S"+str(season)+"E"+str(episode)
episode_id = betaserie.identify_episode(simpsons_id,episode_number)
if action == "watched":
betaserie.mark_episodes_watched(episode_id)
elif action == "unwatched":
betaserie.unmark_episodes_watched(episode_id)
else:
print("Parameter action not in range")
def unwatch_all_episodes():
maximum_number_of_seasons = simpsons_data_object.aggregate(unique_season=Count('season', distinct=True))['unique_season']
print("maximum_number_of_seasons: "+str(maximum_number_of_seasons))
for season in range(1,maximum_number_of_seasons+1):
maximum_number_of_episodes = simpsons_data_object.filter(season=season).count()
print("maximum_number_of_episodes for "+str(season)+": "+str(maximum_number_of_episodes))
for episode in range(1,maximum_number_of_episodes+1):
print("S"+str(season)+"E"+str(episode))
mark_episode_watched(season,episode,"unwatched")