예제 #1
0
def handle_tv_show_episode(data):
    type, filename, show_name = data[0], data[1], data[2]
    assert type == 'tv show'
    if Show.objects.filter(canonical_name__exact=canonical_format(show_name)).count():
        add_episode(data)
        print 'added episode', data
        return True
    else:
        if show_name in is_not_tv_show_cache:
            return False
        matches = tvdb.get_series(show_name)
        match = None
        for m in matches:
            if canonical_format(m['name']) == canonical_format(show_name):
                match = m
                break
        if match:
            if not SuggestedShow.objects.filter(name=match['name']).count():
                SuggestedShow.objects.create(name=match['name'])
                print 'found potential new show "%s"' % canonical_format(show_name)
                return True
        else:
            print 'did not find', show_name, 'on tvdb, ignoring...'
            is_not_tv_show_cache.add(show_name)
    return False
예제 #2
0
def add_episode(data):
    type, filename, show_name = data[0], data[1], data[2]
    assert type == 'tv show'
    print data

    destination_dir = tv_shows_dir
    aired = None
    episode = 0
    show = Show.objects.get(canonical_name__exact=canonical_format(show_name))
    extension = splitext(filename)[-1].strip('. ')
    if isinstance(data[3], datetime):
        aired = data[3]
        season = aired.year
        destination = os.path.join(destination_dir, show.name, 'Season %s' % season, '%s %s.%s' % (show_name, aired.strftime('%Y-%m-%d'), extension))
    else:
        season, episode = data[3]
        destination = os.path.join(destination_dir, show.name, 'Season %s' % int(season), '%s S%02dE%02d.%s' % (show_name, season, episode, extension))
    if destination:
        print 'move %s -> %s' % (os.path.join(downloads_dir, filename), destination)
        if not DEBUG:
            try:
                os.makedirs(os.path.split(destination)[0])
            except:
                pass
            move(os.path.join(downloads_dir, filename), destination)
        Episode.objects.create(season=season, episode=episode, aired=aired, filepath=destination, show=show)
        return True
    return False
예제 #3
0
파일: views.py 프로젝트: jbendjou/CMi
def add_suggested_show(request, suggested_show_id, option):
    s = SuggestedShow.objects.get(pk=suggested_show_id)
    tvdb_result = tvdb.get_series(s.name)
    description = tvdb_result[0]['overview'] if len(tvdb_result) else ''
    Show.objects.create(name=s.name, description=description, canonical_name=canonical_format(s.name), auto_erase=(option=='erase'))
    s.delete()
    if SuggestedShow.objects.filter(ignored=False).count():
        return HttpResponse(':back')
    else:
        return HttpResponse(':back2')
예제 #4
0
파일: sort_movies.py 프로젝트: jbendjou/CMi
def is_movie(c):
    try:
        if c in ('movies', 'tv shows'):
            return False, c
        c = canonical_format(c)
        if c in is_not_movie_cache:
            return False, c
        result = dict([(canonical_format(x['title']), x) for x in ia.search_movie(c) if c])
        if c in result:
            return True, result[c]
        c2 = canonical_format(c.rsplit(' ', 1)[0])
        result = dict([(canonical_format(x['title']), x) for x in ia.search_movie(c2) if c2])
        if c2 in result:
            return True, result[c2]
        # We should also check x['akas'] if available for alternative titles. Example: 'A Separation::International (English title) (imdb display title)'
        print c, 'was not found on IMDB'
        is_not_movie_cache.add(c)
    except IMDbDataAccessError, e:
        print 'IMDbDataAccessError:', e
예제 #5
0
def is_movie(c):
    try:
        if c in ('movies', 'tv shows'):
            return False, c
        c = canonical_format(c)
        if c in is_not_movie_cache:
            return False, c
        result = dict([(canonical_format(x['title']), x) for x in ia.search_movie(c) if c])
        if c in result:
            return True, result[c]
        c2 = canonical_format(c.rsplit(' ', 1)[0])
        result = dict([(canonical_format(x['title']), x) for x in ia.search_movie(c2) if c2])
        if c2 in result:
            return True, result[c2]
        # We should also check x['akas'] if available for alternative titles. Example: 'A Separation::International (English title) (imdb display title)'
        print c, 'was not found on IMDB'
        is_not_movie_cache.add(c)
    except IMDbDataAccessError, e:
        print 'IMDbDataAccessError:', e
예제 #6
0
파일: views.py 프로젝트: boxed/CMi
def add_suggested_show(request, suggested_show_id, option):
    s = SuggestedShow.objects.get(pk=suggested_show_id)
    tvdb_result = tvdb.get_series(s.name)
    description = tvdb_result[0]['overview'] if len(tvdb_result) else ''
    try:
        Show.objects.create(name=s.name,
                            description=description,
                            canonical_name=canonical_format(s.name),
                            auto_erase=(option == 'erase'))
    except IntegrityError:
        pass
    s.delete()
    if SuggestedShow.objects.filter(ignored=False).count():
        return HttpResponse(':back')
    else:
        return HttpResponse(':back2')
예제 #7
0
파일: views.py 프로젝트: boxed/CMi
def add_suggested_show(request, suggested_show_id, option):
    s = SuggestedShow.objects.get(pk=suggested_show_id)
    tvdb_result = tvdb.get_series(s.name)
    description = tvdb_result[0]["overview"] if len(tvdb_result) else ""
    try:
        Show.objects.create(
            name=s.name,
            description=description,
            canonical_name=canonical_format(s.name),
            auto_erase=(option == "erase"),
        )
    except IntegrityError:
        pass
    s.delete()
    if SuggestedShow.objects.filter(ignored=False).count():
        return HttpResponse(":back")
    else:
        return HttpResponse(":back2")