Esempio n. 1
0
File: tv.py Progetto: Zo0x/hedhes
def unwatch_tv(tmdb_id):
    tv = TV.query.filter_by(tmdb_id=tmdb_id).first()
    if tv is None:
        data = tmdb.get_tv(tmdb_id)
        if not data:
            return jsonify({'result': False, 'data': 'TV show not found'})
        tv = TV(data)
    tv.watching = False
    tv.save()
    return jsonify({'result': True, 'data': 'TV show updated: not watching'})
Esempio n. 2
0
File: tv.py Progetto: Zo0x/hedhes
def add_tv(tmdb_id):
    data = tmdb.get_tv(tmdb_id)
    if not data:
        return jsonify({'result': False, 'data': 'TV show not found'})
    tv = TV.query.filter_by(tmdb_id=tmdb_id).first()
    if tv is None:
        tv = TV(data)
    tv.in_library = True
    tv.offline = True
    tv.added = datetime.now()
    tv.save()
    for season in data['seasons']:
        s = tmdb.get_tv_season(tmdb_id, season['season_number'])
        if s is not None:
            tvs = TVSeason(tv.id, s['season_number'])
            tvs.populate(s)
            tvs.save()
            for episode in s['episodes']:
                eps = TVEpisode(tv.id, tvs.id)
                eps.populate(episode)
                eps.save()
    return jsonify({'result': True, 'data': 'TV show added to library'})