Пример #1
0
def search(keyword,
           count=MAX_PAGE,
           regex=None,
           dupe=False,
           min_episode=None,
           max_episode=None):
    try:
        count = int(count)
    except (TypeError, ValueError):
        count = 3
    try:
        data = website.search_by_keyword(keyword, count=count)
        data = website.filter_keyword(data, regex=regex)
        if min_episode is not None:
            data = [x for x in data if x["episode"] >= min_episode]
        if max_episode is not None:
            data = [x for x in data if x["episode"] <= max_episode]
        # for i in data:
        #     if i['episode'] >= min_episode:
        #         r.append(i)

        if not dupe:
            data = website.remove_duplicated_bangumi(data)
        data.sort(key=lambda x: x["episode"])
        return {
            "status":
            "success",
            "message":
            "",
            "options":
            dict(
                keyword=keyword,
                count=count,
                regex=regex,
                dupe=dupe,
                min_episode=min_episode,
                max_episode=max_episode,
            ),
            "data":
            data,
        }
    except Exception as e:
        return {
            "status":
            "error",
            "message":
            str(e),
            "options":
            dict(
                keyword=keyword,
                count=count,
                regex=regex,
                dupe=dupe,
                min_episode=min_episode,
                max_episode=max_episode,
            ),
            "data": [],
        }
Пример #2
0
def search(keyword,
           count=MAX_PAGE,
           regex=None,
           dupe=False,
           min_episode=None,
           max_episode=None):
    try:
        count = int(count)
    except (TypeError, ValueError):
        count = 3
    try:
        data = website.search_by_keyword(keyword, count=count)
        data = website.filter_keyword(data, regex=regex)
        if min_episode is not None:
            data = [x for x in data if x['episode'] >= min_episode]
        if max_episode is not None:
            data = [x for x in data if x['episode'] <= max_episode]
        # for i in data:
        #     if i['episode'] >= min_episode:
        #         r.append(i)

        if not dupe:
            data = website.remove_duplicated_bangumi(data)
        data.sort(key=lambda x: x['episode'])
        return {
            'status':
            'success',
            'message':
            '',
            'options':
            dict(keyword=keyword,
                 count=count,
                 regex=regex,
                 dupe=dupe,
                 min_episode=min_episode,
                 max_episode=max_episode),
            'data':
            data
        }
    except Exception as e:
        return {
            'status':
            'error',
            'message':
            str(e),
            'options':
            dict(keyword=keyword,
                 count=count,
                 regex=regex,
                 dupe=dupe,
                 min_episode=min_episode,
                 max_episode=max_episode),
            'data': []
        }
Пример #3
0
def search(keyword, count=MAX_PAGE, regex=None, dupe=True):
    try:
        count = int(count)
    except (TypeError, ValueError):
        count = 3

    data = website.search_by_keyword(keyword, count=count)
    data = website.filter_keyword(data, regex=regex)
    if not dupe:
        data = website.remove_duplicated_bangumi(data)

    return data
Пример #4
0
def search(keyword, count=MAX_PAGE, regex=None, dupe=False, min_episode=None, max_episode=None):
    try:
        count = int(count)
    except (TypeError, ValueError):
        count = 3
    try:
        data = website.search_by_keyword(keyword, count=count)
        data = website.filter_keyword(data, regex=regex)
        if min_episode is not None:
            data = [x for x in data if x['episode'] >= min_episode]
        if max_episode is not None:
            data = [x for x in data if x['episode'] <= max_episode]
        # for i in data:
        #     if i['episode'] >= min_episode:
        #         r.append(i)

        if not dupe:
            data = website.remove_duplicated_bangumi(data)
        data.sort(key=lambda x: x['episode'])
        return {
            'status': 'success',
            'message': '',
            'options': dict(keyword=keyword,
                            count=count,
                            regex=regex,
                            dupe=dupe,
                            min_episode=min_episode,
                            max_episode=max_episode),
            'data': data}
    except Exception as e:
        return {
            'status': 'error',
            'message': str(e),
            'options': dict(keyword=keyword,
                            count=count,
                            regex=regex,
                            dupe=dupe,
                            min_episode=min_episode,
                            max_episode=max_episode),
            'data': []}