from django.db import models from apps.betaserie.utils import betaserieUtils # Create your models here. class StreamingSiteTestingData(models.Model): url = models.CharField(max_length=1000) addedDate = models.DateField('Published', blank=True, null=True, auto_now_add=True) status = models.CharField(max_length=1000, blank=True, null=True) result = models.CharField(max_length=1000, blank=True, null=True) class Meta: db_table = 'streaming' class StreamingRedirectData(models.Model): name = models.CharField(primary_key=True,max_length=1000, help_text="Name of the show") 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) suffix = models.CharField(max_length=1000, help_text="" ,blank=True, null=True) 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): return name.replace(" ", "") def season_information(self, serie_name): betaserie = betaserieUtils() 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: db_table = 'StreamingRedirect'