Add media export support for duplicates
This commit is contained in:
parent
5540098e96
commit
9d12e9cbe3
@ -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()
|
||||
tracks = tracks[38:]
|
||||
for trackIndex, track in enumerate(tracks):
|
||||
seconds = track["duration"]["seconds"]
|
||||
seconds = int(track["duration"]["seconds"])
|
||||
cleanDuration = f'{seconds // 60}:{seconds % 60}'
|
||||
print(f'{trackIndex} / {len(tracks)}: {track["title"]} - {track["artist"]["name"]} - {cleanDuration}')
|
||||
browser.find_element(By.ID, 'text-input').send_keys(track['title'])
|
||||
@ -74,14 +74,25 @@ with open('rename.txt', 'w') as f:
|
||||
occurrences += 1
|
||||
if occurrences > 1:
|
||||
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
|
||||
else:
|
||||
f.write(f"{track['title']} - {track['artist']['name']}|{track['viperId']}\n")
|
||||
#break
|
||||
#browser.get('chrome://downloads/')
|
||||
#browser.get(AUDIO_LIBRARY_URL)
|
||||
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, '#delete-icon > tp-yt-iron-icon').click()
|
||||
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
|
||||
|
||||
#browser.quit()
|
Loading…
Reference in New Issue
Block a user