예제 #1
0
def query_detail_video_by_obtain_id(obtain_id):
    session = DBSession()
    var = session.query(Video).filter(Video.obtain_id == obtain_id).first()
    print('first', var)
    session.commit()
    # session.close()
    return var
예제 #2
0
def query_video_by_path_and_limit(g_path, count):
    session = DBSession()
    var = session.query(Video).filter(Video.g_path == g_path).limit(count).all()
    for v in var:
        print(g_path, v)
    session.commit()
    print('query_video_by_path_and_limit==', var)
    # session.close()
    return var
예제 #3
0
def query_video_by_type_and_limit(typename, count):
    session = DBSession()
    var = session.query(Video).filter(Video.g_path == genres_dict.get(typename)).limit(count).all()
    for v in var:
        print(typename, v)
    session.commit()
    print('sr==', var)
    # session.close()
    return var
예제 #4
0
def query_group_page_data_by_path(path, page, page_length):
    result_array = []
    session = DBSession()
    total_count = session.query(Video).filter(Video.g_path == path).count()

    start = int(int(page) * int(page_length))
    end = int(start + page_length)
    print('page,page_lenth,start,end,total_count',page,page_length,start,end,total_count)
    selet_cl = [Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster,
                Video.subtitle,
                Video.actors,
                Video.director, Video.total, Video.obtain_id]
    var = session.query().with_entities(Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster,
                                        Video.subtitle,
                                        Video.actors,
                                        Video.director, Video.total, Video.obtain_id).filter(
        Video.g_path == path).slice(start, end).all()
    for v in var:
        item_dict = {}
        for idx, val in enumerate(v):
            item_dict[selet_cl[idx].name] = val
        print(path, v)
        result_array.append(item_dict)
    session.commit()
    print('result_array==', result_array)
    session.close()
    return result_array, int(total_count)
예제 #5
0
def init_genres():
    g_list = []
    Genres.__table__.drop(engine)
    Genres.__table__.create(engine)
    for k, v in genres_dict.items():
        g_list.append(Genres(name=k, path=v))
    session = DBSession()
    session.add_all(g_list)
    session.commit()
    session.close()
예제 #6
0
def query_video_first():
    session = DBSession()
    var = session.query(Video).first()
    print('first', var)
    session.commit()
    session.close()
    return var
예제 #7
0
def query_video_all():
    session = DBSession()
    var = session.query(Video).all()
    print('all size()->', len(var))
    session.commit()
    session.close()
    return var
예제 #8
0
async def addMovie():
    see = DBSession()
    print("start --- add move")
    await asyncio.sleep(2)
    see.add_all(mvList)
    see.commit()
    see.close()
    # for mv in mvList:
    #     print("add-->", mv)
    print("end --- add move--end")
    checkSame()
예제 #9
0
def query_video_all_movie(type):
    session = DBSession()
    var = session.query(Video).filter(Video.g_path == genres_dict.get(type))
    for v in var:
        print(type, v)
    session.commit()
    session.close()
    return var
예제 #10
0
def query_all_genres():
    res = []
    session = DBSession()
    var = session.query(Genres).all()
    for v in var:
        print("genres query:", v)
        res.append(v._asdict())
    session.commit()
    session.close()
    return res
예제 #11
0
def query_video_index(index):
    logging.info('query_video_index:{}'.format("logging.info"))
    session = DBSession()
    var = session.query(Video).filter(Video.g_path == genres_dict.get('电视剧')).limit(index)
    for v in var:
        print('\n')
        logging.info('query_video_index:{}'.format(v))
    session.commit()
    session.close()
    return var
예제 #12
0
def import_all_video(value):
    movieList = []
    # ['编号', '影片名称', '英文名称', '集数', '影片类型', '导演', '演员', '子标题', '影片描述', '片源']
    ob_id = '@{}!{}'.format(value[1], value[5])
    source = value[9]
    mv = Video(title_cn=value[1], title_en=value[2], total=int(value[3]), g_path=genres_dict.get(value[4]),
               director=value[5], actors=value[6], subtitle=value[7], desc=value[8], obtain_id=ob_id)
    mv.sources = parse_source_to_list(source, ob_id)
    # print("insert-->", mv)
    movieList.append(mv)

    se = DBSession()
    se.add_all(movieList)
    se.commit()
    se.close()
예제 #13
0
def query_recommend_video_by_path(path, length):
    result_array = []
    session = DBSession()
    selet_cl = [Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster,
                Video.subtitle,
                Video.actors,
                Video.director, Video.total, Video.obtain_id]
    var = session.query().with_entities(Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster,
                                        Video.subtitle,
                                        Video.actors,
                                        Video.director, Video.total, Video.obtain_id).filter(
        Video.g_path == path).limit(length).all()
    for v in var:
        item_dict = {}
        for idx, val in enumerate(v):
            item_dict[selet_cl[idx].name] = val
        print(path, v)
        result_array.append(item_dict)
    session.commit()
    print('sr==', var)
    session.close()
    return result_array
예제 #14
0
def checkSame():
    see = DBSession()
    mv4 = Video(title_cn='wo shi 4')
    mv5 = Video(title_cn='wo shi 1')
    see.add(mv4)
    print('same-->mv4===', mv4)
    see.query(mv5)
    outUser = see.query(Video).filter_by(title_cn='wo shi 4').first()
    outUser2 = see.query(Video).filter_by(title_cn='wo shi 1').first()
    print('same-->out===', outUser)
    print('same-->', mv5 is outUser2)

    see.commit()
    see.close()