Exemplo n.º 1
0
def video_search(videoID, new_regist_videoid=0):
    while True:
        # 動画IDの形式(sm,so,nm)を切り取る
        videoID = videoID[2:]
        if new_regist_videoid == 0:
            # 更新した日時が一番新しい動画IDを取得する
            new_regist_videoid = new_videoid_select()
        # new_regist_videoidに動画IDの情報があればそのIDから取得開始、なければ動画ID1から取得開始
        if new_regist_videoid == None:
            for i in range(1, int(videoID)):                
                format_rand_videoID = format_video_search(i)

                if format_rand_videoID == "novideo":
                    continue
                else:
                    print ("------------------------------")
                    print(format_rand_videoID + str(i))
                    # 動画ID取得したらDBに登録
                    db_regist(format_rand_videoID + str(i))
            new_regist_videoid = 1
        else:    
            for i in range(int(new_regist_videoid), int(videoID)):
                format_rand_videoID = format_video_search(i)

                if format_rand_videoID == "novideo":
                    continue
                else:
                    print ("------------------------------")
                    print(format_rand_videoID + str(i))
                    # 動画ID取得したらDBに登録
                    db_regist(format_rand_videoID + str(i))
            new_regist_videoid = 1
Exemplo n.º 2
0
def video_search(videoID, new_regist_videoid=0):
    while True:
        # 動画IDの形式(sm,so,nm)を切り取る
        # videoID = videoID[2:]
        if new_regist_videoid == 0:
            # 更新した日時が一番新しい動画IDを取得する
            new_regist_videoid = new_videoid_select()

        novideo_count = 0
        # new_regist_videoidに動画IDの情報があればそのIDから取得開始、なければ動画ID1から取得開始
        if new_regist_videoid == None or new_regist_videoid == "":
            for i in range(20000001, int(videoID)):
                format_rand_videoID = format_video_search(i)

                if format_rand_videoID == "novideo":
                    novideo_count += 1
                    if novideo_count >= 10000:
                        break
                    # 以前動画情報が登録してあればDBに状態を登録
                    # db_regist_novideo(str(i))
                    continue
                else:
                    novideo_count = 0
                    print("------------------------------")
                    print(format_rand_videoID + str(i))
                    # 動画ID取得したらDBに登録
                    db_regist(format_rand_videoID + str(i))

                ### 04:00まで実行する為に時間測定(本番環境用) ###
                dt = measure_datetime.datetime.now()
                date_now = str(dt.hour) + ':' + str(dt.minute)
                print(date_now)
                if (date_now == "4:0" or date_now == "4:1" or date_now == "4:2"
                        or date_now == "4:3" or date_now == "4:4"
                        or date_now == "4:5" or date_now == "4:6"
                        or date_now == "4:7" or date_now == "4:8"
                        or date_now == "4:9" or date_now == "4:10"):
                    sys.exit()

            new_regist_videoid = 20000001
        else:
            for i in range(int(new_regist_videoid), int(videoID)):
                format_rand_videoID = format_video_search(i)

                if format_rand_videoID == "novideo":
                    novideo_count += 1
                    if novideo_count >= 10000:
                        break
                    # 以前動画情報が登録してあればDBに状態を登録
                    # db_regist_novideo(str(i))
                    continue
                else:
                    novideo_count = 0
                    print("------------------------------")
                    print(format_rand_videoID + str(i))
                    # 動画ID取得したらDBに登録
                    db_regist(format_rand_videoID + str(i))

                ### 04:00まで実行する為に時間測定(本番環境用) ###
                dt = measure_datetime.datetime.now()
                date_now = str(dt.hour) + ':' + str(dt.minute)
                print(date_now)
                if (date_now == "4:0" or date_now == "4:1" or date_now == "4:2"
                        or date_now == "4:3" or date_now == "4:4"
                        or date_now == "4:5" or date_now == "4:6"
                        or date_now == "4:7" or date_now == "4:8"
                        or date_now == "4:9" or date_now == "4:10"):
                    sys.exit()

            new_regist_videoid = 20000001