From 9a8493f39788ce73d54b4f3d9b4ada1674ecb583 Mon Sep 17 00:00:00 2001 From: Benjamin_Loison Date: Sat, 4 Feb 2023 19:09:51 +0100 Subject: [PATCH] Add consistency note on `Home` page --- Home.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Home.md diff --git a/Home.md b/Home.md new file mode 100644 index 0000000..9a21035 --- /dev/null +++ b/Home.md @@ -0,0 +1,58 @@ +Check some consistency (actually very bad) from YouTube Audio library using this Python script: + +```py +import os, json, subprocess + +path = '/home/benjamin/Desktop/bens_folder/dev/yt/audio_library' + +os.chdir(path) + +with open('sound_effects.json') as json_file: + tracks = json.load(json_file) + +def execute(command): + return subprocess.check_output(command, shell = True).decode('utf-8') + +path = '/home/benjamin/Downloads' + +os.chdir(path) + +ids = {} + +for track in tracks: + #if track['title'] == 'Organic Guitar House': + # print(track) + #continue + #print(track) + duration = track['duration'] + #if not 'seconds' in duration and 'nanos' in duration and duration['nanos'] >= 10 ** 9: + # print('both') + #continue + duration = duration['nanos'] if 'nanos' in duration else int(duration['seconds']) * (10 ** 9) + # Add category for sound effect: _{track['attributes']['category']} + attributes = track['attributes'] + category = attributes['category'] if 'category' in attributes else None + id = f"{track['artist']['name']}_{track['title']}_{duration}_{category}" + if id in ids: + print(id) + fileName = f"{track['title']} - {track['artist']['name']}" + command = f'cmp "{fileName}.mp3" "{fileName}(1).mp3"' + #print(command) + #execute(command) + alreadyRegistered = ids[id] + track['trackId'] = alreadyRegistered['trackId'] + track['viperId'] = alreadyRegistered['viperId'] + #track['attributes']['category'] = alreadyRegistered['attributes']['category'] + #track['artist']['name'] = alreadyRegistered['artist']['name'] + track['duration']['seconds'] = alreadyRegistered['duration']['seconds'] + track['publishTime']['seconds'] = alreadyRegistered['publishTime']['seconds'] + if track != alreadyRegistered: + print('different') + print(track) + print(alreadyRegistered) + #break + #print('Already in `ids`!') + #break + else: + ids[id] = track +``` \ No newline at end of file