Пример #1
0
	def __update__(self):
		api = APIseries()

		# Actualizar serie
		data = api.getDictSerie(self.theTvdbID)
		self.nombre = data['title']
		self.descripcion = data['overview']
		self.imagen = data['banner']
		self.genero = data['genre']
		self.fechaEmision = data['Airs_DayOfWeek']
		self.estado = data['status']
		self.save()

		# Actualizar todos los capítulos de esta serie
		structuredEpisodes = api.getStructuredEpisodes(self.theTvdbID)
		for episodeId, title, season, number, airdate in structuredEpisodes:
			try:
				c = Capitulo.objects.get(theTvdbID=episodeId)
				param = {"titulo": title, "airdate": airdate}
				c.__update__(data=param)
			except Capitulo.DoesNotExist:
				c = Capitulo(serie=self, theTvdbID=episodeId, temporada=season, numero=number, titulo=title, estado=-1, airDate=airdate)
				c.save()
			crontab.setAnalysisSchedule(c)
		crontab.saveTempChanges(crontab.path)
Пример #2
0
    def __update__(self):
        api = APIseries()

        # Actualizar serie
        data = api.getDictSerie(self.theTvdbID)
        self.nombre = data['title']
        self.descripcion = data['overview']
        self.imagen = data['banner']
        self.genero = data['genre']
        self.fechaEmision = data['Airs_DayOfWeek']
        self.estado = data['status']
        self.save()

        # Actualizar todos los capítulos de esta serie
        structuredEpisodes = api.getStructuredEpisodes(self.theTvdbID)
        for episodeId, title, season, number, airdate in structuredEpisodes:
            try:
                c = Capitulo.objects.get(theTvdbID=episodeId)
                param = {"titulo": title, "airdate": airdate}
                c.__update__(data=param)
            except Capitulo.DoesNotExist:
                c = Capitulo(serie=self,
                             theTvdbID=episodeId,
                             temporada=season,
                             numero=number,
                             titulo=title,
                             estado=-1,
                             airDate=airdate)
                c.save()
            crontab.setAnalysisSchedule(c)
        crontab.saveTempChanges(crontab.path)
Пример #3
0
def addSerie(request, identifier):
    # Comprobar si el usuario esta autenticado
    if not request.user.is_authenticated():
        return redirect('index')

    # Comprobar si la serie ya está en la base de datos
    try:
        s = Serie.objects.get(theTvdbID=identifier)
        userSerie = UserSerie.objects.get(serie=s)

        # Si la serie ya existe para ese usuario devolver un warning
        series = getSeriesForUser(request)
        context = generateContext(request=request,
                                  title="Control panel",
                                  series=series)
        setContextWarning(context, "You already have that show")
        return render(request, 'series/index-message.html', context)

    except Serie.DoesNotExist:
        # Si no está -> añadir a la base de datos y al usuario
        api = APIseries()
        data = api.getDictSerie(identifier)

        # Añadir serie a la base de datos
        s = Serie(theTvdbID = identifier, nombre = data['title'], descripcion = data['overview'], imagen = data['banner'], \
         genero = data['genre'], fechaEmision = data['Airs_DayOfWeek'], estado = data['status'], \
         tiempoAnalisis = 24, numeroTorrents = 5, limiteSubida = 64, limiteBajada = 1024)
        s.save()

        # Añadir capítulos a la base de datos
        episodeData = api.getStructuredEpisodes(identifier)
        for episodeId, title, season, number, airdate in episodeData:
            c = Capitulo(serie=s,
                         theTvdbID=episodeId,
                         temporada=season,
                         numero=number,
                         titulo=title,
                         estado=-1,
                         airDate=airdate)
            c.save()
            crontab.setAnalysisSchedule(c)
        crontab.saveTempChanges(crontab.path)

        # Añadir serie al usuario correspondiente
        userSerie = UserSerie(user=auth.get_user(request), serie=s)
        userSerie.save()

    except UserSerie.DoesNotExist:
        # La serie existe en la base de datos, pero no está asociada al usuario
        userSerie = UserSerie(user=auth.get_user(request), serie=s)
        userSerie.save()

    series = getSeriesForUser(request)
    context = generateContext(request=request,
                              title="Control panel",
                              series=series)
    setContextSuccess(context, "Show was added to your account")
    return render(request, 'series/index-message.html', context)
Пример #4
0
def addSerie(request, identifier):
	# Comprobar si el usuario esta autenticado
	if not request.user.is_authenticated():
		return redirect('index')

	# Comprobar si la serie ya está en la base de datos
	try:
		s = Serie.objects.get(theTvdbID=identifier)
		userSerie = UserSerie.objects.get(serie=s)

		# Si la serie ya existe para ese usuario devolver un warning
		series = getSeriesForUser(request)
		context = generateContext(request=request, title="Control panel", series=series)
		setContextWarning(context, "You already have that show")
		return render(request, 'series/index-message.html', context)

	except Serie.DoesNotExist:
		# Si no está -> añadir a la base de datos y al usuario
		api = APIseries()
		data = api.getDictSerie(identifier)

		# Añadir serie a la base de datos
		s = Serie(theTvdbID = identifier, nombre = data['title'], descripcion = data['overview'], imagen = data['banner'], \
			genero = data['genre'], fechaEmision = data['Airs_DayOfWeek'], estado = data['status'], \
			tiempoAnalisis = 24, numeroTorrents = 5, limiteSubida = 64, limiteBajada = 1024)
		s.save()

		# Añadir capítulos a la base de datos
		episodeData = api.getStructuredEpisodes(identifier)
		for episodeId, title, season, number, airdate in episodeData:
			c = Capitulo(serie=s, theTvdbID=episodeId, temporada=season, numero=number, titulo=title, estado=-1, airDate=airdate)
			c.save()
			crontab.setAnalysisSchedule(c)
		crontab.saveTempChanges(crontab.path)

		# Añadir serie al usuario correspondiente
		userSerie = UserSerie(user=auth.get_user(request), serie=s)
		userSerie.save()

	except UserSerie.DoesNotExist:
		# La serie existe en la base de datos, pero no está asociada al usuario
		userSerie = UserSerie(user=auth.get_user(request), serie=s)
		userSerie.save()

	series = getSeriesForUser(request)
	context = generateContext(request=request, title="Control panel", series=series)
	setContextSuccess(context, "Show was added to your account")
	return render(request, 'series/index-message.html', context)
Пример #5
0
def dailyUpdate():
	url = "http://www.thetvdb.com/api/EB224CCBC0C8E52F/updates/updates_day.xml"
	resp = requests.get(url)

	updates = objectify.fromstring(resp.content)
	updatedSeries = [int(serie.id) for serie in updates.Series]
	updatedEpisodes = [int(episode.id) for episode in updates.Episode]

	localSeries = Serie.objects.all()
	for serie in localSeries:
		if serie.theTvdbID in updatedSeries:
			serie.__update__()

	localEpisodes = Capitulo.objects.all()
	for episode in localEpisodes:
		if episode.theTvdbID in updatedEpisodes:
			episode.__update__()
			crontab.setAnalysisSchedule(episode)

	crontab.saveTempChanges(crontab.path)
Пример #6
0
def dailyUpdate():
    url = "http://www.thetvdb.com/api/EB224CCBC0C8E52F/updates/updates_day.xml"
    resp = requests.get(url)

    updates = objectify.fromstring(resp.content)
    updatedSeries = [int(serie.id) for serie in updates.Series]
    updatedEpisodes = [int(episode.id) for episode in updates.Episode]

    localSeries = Serie.objects.all()
    for serie in localSeries:
        if serie.theTvdbID in updatedSeries:
            serie.__update__()

    localEpisodes = Capitulo.objects.all()
    for episode in localEpisodes:
        if episode.theTvdbID in updatedEpisodes:
            episode.__update__()
            crontab.setAnalysisSchedule(episode)

    crontab.saveTempChanges(crontab.path)