예제 #1
0
def test_tags():
    file_abs_path = "D:\\Automatica\\Python\\PyCharmProjects\\Kevolehc\\Kevolehc\\youtube\\" \
                    "files\\monitors\\GameChops" \
                    "\\605 - GameChops - Undertale Remix - Arcien - Heartache (from _Hopes & Dreams_) - GameChops.mp3"
                    # "\\1053 - Extra Credits - ♫ Policing London - _Alleyways & Truncheons_ - Extra History Music.mp4"
                    # "\\677 - ThePrimeThanatos - 'Back To The 80's' _ Best of Synthwave And Retro Electro Music Mix _ Vol. 21.mp3"

    if file_abs_path.endswith(constants.MP3):
        tags = {
            "genre": "GameChops",
            # "title": "'Back To The 80's | Best of Synthwave And Retro Electro Music Mix | Vol. 21",
            "title": "Undertale & Remix - Arcien - & Heartache (from \"Hopes & ss & Dreams\")  & \" - GameChops \" zz \" &",
            "track": "605",
            "comment": "by Mefodii"
        }
    else:
        tags = {
            "author": "ExtraCreditz",
            "title": "♫ Policing London - \"Alleyways & Truncheons\" - Extra History Music",
            "track": str(1053),
            "copyright": "ExtraCreditz",
            "episode_id": "EO_16t_Fe5s",
            "comment": "by Mefodii"
        }

    print(file_abs_path)
    print(tags)
    print(File.exists(file_abs_path))

    Ffmpeg.add_tags(file_abs_path, tags)
예제 #2
0
def update_extra_credits():
    db_file = '\\'.join([paths.DB_LOG_PATH, "ExtraCreditz.txt"])
    db_json = File.get_json_data(db_file)
    check_path = "G:\\Filme\\ExtraCreditz"
    files_list = list_files_sub(check_path)

    for element in files_list:
        abs_path = element["path"] + "\\" + element["filename"]
        if abs_path.endswith(constants.MP4):
            metadata = Ffmpeg.metadata_to_json(Ffmpeg.get_metadata(abs_path))
            print(metadata)
            track = int(metadata.get("TRACK", -1))
            episode_id = metadata.get("EPISODE_ID", None)
            if (track > 0) and (episode_id is None):
                for key, value in db_json.items():
                    if value["NUMBER"] == track and value["STATUS"] == "UNABLE":
                        print(key, track)
                        tags = {
                            "episode_id": key
                        }
                        if File.exists(abs_path):
                            Ffmpeg.add_tags(abs_path, tags)

                        value["STATUS"] = "DOWNLOADED"

    File.write_json_data(db_file, db_json)
예제 #3
0
def test_download_videos(links_json):
    video_list = []
    q_list = []
    name = "CriticalRole"
    format = constants.MKV
    output_directory = paths.YOUTUBE_RESULT_PATH

    data = {}
    for item in links_json:
        item_id = item["LINK"][32:]
        item_nr = item["TRACK"]
        data[item_id] = item_nr

    dk_file = '/'.join([paths.INPUT_FILES_PATH, paths.YOUTUBE_DK_FILE])
    worker = YoutubeWorker(dk_file)
    videos = worker.get_videos(list(data.keys()))

    for item in videos:
        print(item)
        yt_video_params = YoutubeVideo.parse_json_yt_response(item)
        yt_video = YoutubeVideo(yt_video_params[YoutubeVideo.ID], yt_video_params[YoutubeVideo.TITLE],
                                yt_video_params[YoutubeVideo.PUBLISHED_AT],
                                yt_video_params[YoutubeVideo.CHANNEL_NAME], data.get(yt_video_params[YoutubeVideo.ID]))
        video_list.append(yt_video)

    for video in video_list:
        file_name = " - ".join([str(video.number), name, str(video.title)])
        save_location = output_directory

        queue = YoutubeQueue(video.id, file_name, save_location, format)
        print(repr(queue))

        video.file_name = queue.file_name
        video.save_location = queue.save_location

        q_list.append(queue)

    q_len = str(len(q_list))
    i = 0
    for queue in q_list:
        i += 1
        q_progress = str(i) + "/" + q_len

        result_file = queue.save_location + "\\" + queue.file_name + "." + queue.save_format
        if File.exists(result_file):
            print("Queue ignored, file exist: " + q_progress)
        else:
            print("Process queue: " + q_progress + " - " + result_file)
            try:
                YoutubeDownloader.download(queue)
            except DownloadError:
                print("Unable to download - " + queue.link)

    for video in video_list:
        file_extension = format
        file_abs_path = "\\".join([video.save_location, video.file_name]) + "." + file_extension

        tags = {
            "author": name,
            "title": video.title,
            "track": str(video.number),
            "copyright": name,
            "episode_id": video.id,
            "comment": "by Mefodii"
        }

        if File.exists(file_abs_path):
            Ffmpeg.add_tags(file_abs_path, tags)
        else:
            print("Not found: " + file_abs_path)