Exemplo n.º 1
0
def process_subtitle(data):
    '''get subtitle group name from links
    '''
    result = []
    for s in data:
        f = Subtitle(id=s['tag_id'], name=s['name'])
        if not f.select():
            f.save()
        result.append(s['tag_id'])
    return result
Exemplo n.º 2
0
    def fetch(self, save=False, group_by_weekday=True):
        bangumi_result, subtitle_group_result = self.fetch_bangumi_calendar_and_subtitle_group(
        )
        if subtitle_group_result:
            for subtitle_group in subtitle_group_result:
                s = Subtitle(id=_unicode(subtitle_group['id']),
                             name=_unicode(subtitle_group['name']))
                if not s.select():
                    s.save()
        if not bangumi_result:
            print('no result return None')
            return []

        if save:
            for bangumi in bangumi_result:
                self.save_data(bangumi)
        if group_by_weekday:
            result_group_by_weekday = defaultdict(list)
            for bangumi in bangumi_result:
                result_group_by_weekday[bangumi['update_time'].lower()].append(
                    bangumi)
            bangumi_result = result_group_by_weekday
        return bangumi_result