Add media export support for duplicates

This commit is contained in:
Benjamin Loison 2023-02-04 19:45:30 +01:00
parent 5540098e96
commit 9d12e9cbe3
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -36,7 +36,7 @@ with open('rename.txt', 'w') as f:
browser.find_element(By.CSS_SELECTOR, '#text-item-2 > ytcp-ve > div > div > yt-formatted-string').click() browser.find_element(By.CSS_SELECTOR, '#text-item-2 > ytcp-ve > div > div > yt-formatted-string').click()
tracks = tracks[38:] tracks = tracks[38:]
for trackIndex, track in enumerate(tracks): for trackIndex, track in enumerate(tracks):
seconds = track["duration"]["seconds"] seconds = int(track["duration"]["seconds"])
cleanDuration = f'{seconds // 60}:{seconds % 60}' cleanDuration = f'{seconds // 60}:{seconds % 60}'
print(f'{trackIndex} / {len(tracks)}: {track["title"]} - {track["artist"]["name"]} - {cleanDuration}') print(f'{trackIndex} / {len(tracks)}: {track["title"]} - {track["artist"]["name"]} - {cleanDuration}')
browser.find_element(By.ID, 'text-input').send_keys(track['title']) browser.find_element(By.ID, 'text-input').send_keys(track['title'])
@ -74,14 +74,25 @@ with open('rename.txt', 'w') as f:
occurrences += 1 occurrences += 1
if occurrences > 1: if occurrences > 1:
print('multiple occurrences') print('multiple occurrences')
# This isn't a clean solution.
time.sleep(1)
browser.get('chrome://downloads/')
for occurrence in range(occurrences):
url = browser.find_element(By.XPATH, f'/html/body/downloads-manager').shadow_root.find_element(By.ID, 'downloadsList').find_element(By.ID, f'frb{occurrences - occurrence - 1}').shadow_root.find_element(By.ID, 'url').get_attribute('href')
viperId = url.split('&id=')[1].split('&')[0]
print(viperId)
occurrenceStr = '' if occurrence == 0 else f'({occurrence})'
f.write(f"{track['title']} - {track['artist']['name']}{occurrenceStr}|{viperId}\n")
browser.get(AUDIO_LIBRARY_URL)
break break
else:
f.write(f"{track['title']} - {track['artist']['name']}|{track['viperId']}\n")
#break #break
#browser.get('chrome://downloads/')
#browser.get(AUDIO_LIBRARY_URL)
else: else:
browser.find_element(By.CSS_SELECTOR, 'ytcp-button.style-scope:nth-child(1) > div:nth-child(2)').click() browser.find_element(By.CSS_SELECTOR, 'ytcp-button.style-scope:nth-child(1) > div:nth-child(2)').click()
browser.find_element(By.CSS_SELECTOR, '#delete-icon > tp-yt-iron-icon').click()
f.write(f"{track['title']} - {track['artist']['name']}|{track['viperId']}\n") f.write(f"{track['title']} - {track['artist']['name']}|{track['viperId']}\n")
browser.find_element(By.CSS_SELECTOR, '#delete-icon > tp-yt-iron-icon').click()
#break #break
#browser.quit() #browser.quit()