From 29c7e452b0cb2e52178573b034259d8a610692f6 Mon Sep 17 00:00:00 2001 From: MCorange Date: Sat, 14 Sep 2024 19:00:43 +0300 Subject: [PATCH] Added playlist downloading to cli --- manifest.json | 1128 +++++++++++++------------- src/commands/add.rs | 47 +- src/commands/gui/song_edit_window.rs | 9 +- src/commands/mod.rs | 5 + src/config/cli.rs | 12 +- src/downloader.rs | 55 +- src/manifest/mod.rs | 14 +- src/process_manager.rs | 3 + 8 files changed, 669 insertions(+), 604 deletions(-) diff --git a/manifest.json b/manifest.json index ebba660..09de885 100644 --- a/manifest.json +++ b/manifest.json @@ -1,58 +1,66 @@ { "format": "m4a", "playlists": { + "lietuviskos/sel": { + "songs": { + "SEL - Leisk": { + "url": "https://youtu.be/DDPmFMrffXQ", + "typ": "Youtube" + }, + "SEL - Lyja": { + "url": "https://www.youtube.com/watch?v=KL6JBWnXCxw", + "typ": "Youtube" + }, + "SEL - Gyvenimo man vieno neuztenka": { + "url": "https://youtu.be/7Gd9XaEG5o4", + "typ": "Youtube" + }, + "SEL - Tik Tok": { + "url": "https://youtu.be/RkaIUateIxg", + "typ": "Youtube" + }, + "SEL - Ten kur sapnai": { + "url": "https://youtu.be/GDj3NgjDbRo", + "typ": "Youtube" + }, + "SEL - Tarp amzinybes": { + "url": "https://youtu.be/UfPj-0QpGFA", + "typ": "Youtube" + }, + "SEL - Uzmerkiu akis": { + "url": "https://youtu.be/SdWj06XRZms?si=9TNGzjK9ITom-jaD", + "typ": "Youtube" + }, + "SEL - Skrendu": { + "url": "https://youtu.be/G5Q_asvrXlA", + "typ": "Youtube" + }, + "SEL - Nes as tik vejas": { + "url": "https://youtu.be/acMG37IZ6z8", + "typ": "Youtube" + }, + "SEL - As ziuriu i tave pasauli": { + "url": "https://youtu.be/_SPDjl80kKw", + "typ": "Youtube" + }, + "SEL - Ten kazkur giliai": { + "url": "https://youtu.be/N7YNlegeiqs?si=9BBH6hjrgOjJ01Nz", + "typ": "Youtube" + } + } + }, "electronic": { "songs": { - "Zombie Nation - Kernkraft 400": { - "url": "https://www.youtube.com/watch?v=z5LW07FTJbI", + "Benny Benassi - Satisfaction": { + "url": "https://www.youtube.com/watch?v=a0fkNdPiIL4", "typ": "Youtube" }, "MONEY ON THE DASH": { "url": "https://open.spotify.com/track/6nVEV8CIU4dw12oVZbKJtl", "typ": "Spotify" }, - "Benny Benassi - Satisfaction": { - "url": "https://www.youtube.com/watch?v=a0fkNdPiIL4", - "typ": "Youtube" - } - } - }, - "rusiskos": { - "songs": { - "Eldzej and Feduk - Rozovoe vino": { - "url": "https://www.youtube.com/watch?v=S9oXj3a4gZ4", - "typ": "Youtube" - }, - "Katja lel - moi marmeladni (paprobui mua mua)": { - "url": "https://www.youtube.com/watch?v=0JMdXFHo5SY", - "typ": "Youtube" - }, - "Dzaro and hansa - Visky Kola karaleva trans pola": { - "url": "https://www.youtube.com/watch?v=fflrMvZ2HtA", - "typ": "Youtube" - }, - "Raim & Artur feat. Zhenis - Diskoteka is 90 hit": { - "url": "https://www.youtube.com/watch?v=GfBhxlNhrn0", - "typ": "Youtube" - }, - "Topolini puh": { - "url": "https://www.youtube.com/watch?v=UUryvYF8tUs", - "typ": "Youtube" - }, - "Ruki Verch - 18 mne uze": { - "url": "https://www.youtube.com/watch?v=Hxab_Sr132o", - "typ": "Youtube" - }, - "Arash - Temptation": { - "url": "https://www.youtube.com/watch?v=6X3ZJh762-I", - "typ": "Youtube" - }, - "Kanikuli": { - "url": "https://www.youtube.com/watch?v=GNMiDZTL7jo", - "typ": "Youtube" - }, - "Pimp Schwab - vse shto nas ne Ubivaet": { - "url": "https://www.youtube.com/watch?v=NTEXFyUE9Ww", + "Zombie Nation - Kernkraft 400": { + "url": "https://www.youtube.com/watch?v=z5LW07FTJbI", "typ": "Youtube" } } @@ -65,12 +73,20 @@ } } }, - "alt": { + "lietuviskos/rave": { "songs": { - "ROMANCEPLANET - PLAIN WHITE TEE": { - "url": "https://www.youtube.com/watch?v=tdVQbNwjGac", + "VainHouse - Malunas Prie Kelio": { + "url": "https://www.youtube.com/watch?v=bbwuNjDXCiM", "typ": "Youtube" }, + "Sokoledas - Mano Skonis Sokolado (Matuze & Arnisxd Remix)": { + "url": "https://www.youtube.com/watch?v=hb41bfQxiM0", + "typ": "Youtube" + } + } + }, + "alt": { + "songs": { "ROMANCEPLANET - FALL FROM THE SKY": { "url": "https://www.youtube.com/watch?v=HMhzxzXBisw", "typ": "Youtube" @@ -82,69 +98,513 @@ "Artemas - i like the way you kiss me": { "url": "https://www.youtube.com/watch?v=ODDRRXMi22E", "typ": "Youtube" - } - } - }, - "pop": { - "songs": { - "Modern Talking - You're My Heart, You're My Soul": { - "url": "https://www.youtube.com/watch?v=4kHl4FoK1Ys", - "typ": "Youtube" }, - "Icona Pop - I Love It": { - "url": "https://www.youtube.com/watch?v=UxxajLWwzqY", - "typ": "Youtube" - }, - "Mr President - Coco Jumbo": { - "url": "https://www.youtube.com/watch?v=cOrc37wNUqU", - "typ": "Youtube" - }, - "Cheri cheri lady": { - "url": "https://www.youtube.com/watch?v=lrIKt5uDWZo", - "typ": "Youtube" - }, - "LT United - We are the winners": { - "url": "https://www.youtube.com/watch?v=DBAdOlQPbwg", - "typ": "Youtube" - }, - "Pitbul - Fireball": { - "url": "https://www.youtube.com/watch?v=HMqgVXSvwGo", - "typ": "Youtube" - }, - "Green Day - Basket Case": { - "url": "https://www.youtube.com/watch?v=wZ8eZRxFA-0", + "ROMANCEPLANET - PLAIN WHITE TEE": { + "url": "https://www.youtube.com/watch?v=tdVQbNwjGac", "typ": "Youtube" } } }, "rave": { "songs": { - "Mason - Perfect remix 1991": { - "url": "https://open.spotify.com/track/1VKWQgq0g2uKtgNfL0ceNM?si=b3f1dc504ddb41ed", - "typ": "Spotify" + "EVERYTHING WHAT": { + "url": "https://www.youtube.com/watch?v=Gjdsq4kc5cA", + "typ": "Youtube" }, "Tricky Disco": { "url": "https://www.youtube.com/watch?v=t78qVdbAiXw", "typ": "Youtube" }, + "Mason - Perfect remix 1991": { + "url": "https://open.spotify.com/track/1VKWQgq0g2uKtgNfL0ceNM?si=b3f1dc504ddb41ed", + "typ": "Spotify" + }, "DR. VODKA - Tricky Disco": { "url": "https://www.youtube.com/watch?v=IknAUhl3i2o", "typ": "Youtube" - }, - "EVERYTHING WHAT": { - "url": "https://www.youtube.com/watch?v=Gjdsq4kc5cA", - "typ": "Youtube" } } }, - "lietuviskos/rave": { + "hip-hop": { "songs": { - "Sokoledas - Mano Skonis Sokolado (Matuze & Arnisxd Remix)": { - "url": "https://www.youtube.com/watch?v=hb41bfQxiM0", + "Drenchill - Freed from Desire": { + "url": "https://www.youtube.com/watch?v=6b6FBneAENQ", "typ": "Youtube" }, - "VainHouse - Malunas Prie Kelio": { - "url": "https://www.youtube.com/watch?v=bbwuNjDXCiM", + "Afroman - Because I Got High": { + "url": "https://www.youtube.com/watch?v=WeYsTmIzjkw", + "typ": "Youtube" + } + } + }, + "pop": { + "songs": { + "Icona Pop - I Love It": { + "url": "https://www.youtube.com/watch?v=UxxajLWwzqY", + "typ": "Youtube" + }, + "Green Day - Basket Case": { + "url": "https://www.youtube.com/watch?v=wZ8eZRxFA-0", + "typ": "Youtube" + }, + "Pitbul - Fireball": { + "url": "https://www.youtube.com/watch?v=HMqgVXSvwGo", + "typ": "Youtube" + }, + "Cheri cheri lady": { + "url": "https://www.youtube.com/watch?v=lrIKt5uDWZo", + "typ": "Youtube" + }, + "Mr President - Coco Jumbo": { + "url": "https://www.youtube.com/watch?v=cOrc37wNUqU", + "typ": "Youtube" + }, + "Modern Talking - You're My Heart, You're My Soul": { + "url": "https://www.youtube.com/watch?v=4kHl4FoK1Ys", + "typ": "Youtube" + }, + "LT United - We are the winners": { + "url": "https://www.youtube.com/watch?v=DBAdOlQPbwg", + "typ": "Youtube" + } + } + }, + "rusiskos": { + "songs": { + "Eldzej and Feduk - Rozovoe vino": { + "url": "https://www.youtube.com/watch?v=S9oXj3a4gZ4", + "typ": "Youtube" + }, + "Pimp Schwab - vse shto nas ne Ubivaet": { + "url": "https://www.youtube.com/watch?v=NTEXFyUE9Ww", + "typ": "Youtube" + }, + "Raim & Artur feat. Zhenis - Diskoteka is 90 hit": { + "url": "https://www.youtube.com/watch?v=GfBhxlNhrn0", + "typ": "Youtube" + }, + "Ruki Verch - 18 mne uze": { + "url": "https://www.youtube.com/watch?v=Hxab_Sr132o", + "typ": "Youtube" + }, + "Arash - Temptation": { + "url": "https://www.youtube.com/watch?v=6X3ZJh762-I", + "typ": "Youtube" + }, + "Dzaro and hansa - Visky Kola karaleva trans pola": { + "url": "https://www.youtube.com/watch?v=fflrMvZ2HtA", + "typ": "Youtube" + }, + "Topolini puh": { + "url": "https://www.youtube.com/watch?v=UUryvYF8tUs", + "typ": "Youtube" + }, + "Katja lel - moi marmeladni (paprobui mua mua)": { + "url": "https://www.youtube.com/watch?v=0JMdXFHo5SY", + "typ": "Youtube" + }, + "Kanikuli": { + "url": "https://www.youtube.com/watch?v=GNMiDZTL7jo", + "typ": "Youtube" + } + } + }, + "lietuviskos": { + "songs": { + "Elektra - Juda Tavo rankos": { + "url": "https://www.youtube.com/watch?v=k2RuDoudnOE", + "typ": "Youtube" + }, + "Juodas Garvezys (Remix)": { + "url": "https://www.youtube.com/watch?v=D-7qQbXHSAw", + "typ": "Youtube" + }, + "Mr.Bullet - UZ MUS IR JUS": { + "url": "https://www.youtube.com/watch?v=85q_7jXEgH8", + "typ": "Youtube" + }, + "NL - Juodas Golfas": { + "url": "https://www.youtube.com/watch?v=f2-ZmElSvPc", + "typ": "Youtube" + }, + "Depresinis - LEDINE": { + "url": "https://www.youtube.com/watch?v=qugvChkXMLk", + "typ": "Youtube" + }, + "Tnn - Parukom": { + "url": "https://www.youtube.com/watch?v=v9pBZK2RIPI", + "typ": "Youtube" + }, + "Grupe MX - 1.9 TDI": { + "url": "https://www.youtube.com/watch?v=8FBr5GQXsI8", + "typ": "Youtube" + }, + "Zilvinas Zvagulis - Amerikonas grizo sunus": { + "url": "https://www.youtube.com/watch?v=UvzJEz5ADY8", + "typ": "Youtube" + }, + "Depresinis - Volkswagina": { + "url": "https://www.youtube.com/watch?v=1lZR1VKsQHo", + "typ": "Youtube" + }, + "69 Danguje - Gyvenu": { + "url": "https://www.youtube.com/watch?v=HMXlhmAoux4", + "typ": "Youtube" + }, + "AVA - Eik Tu NA": { + "url": "https://www.youtube.com/watch?v=yRf3ijaIgOg", + "typ": "Youtube" + }, + "NL - Pasitusinam": { + "url": "https://www.youtube.com/watch?v=WhSFudvloog", + "typ": "Youtube" + }, + "Judam Lietuvoj": { + "url": "https://www.youtube.com/watch?v=WDzWSEgSy5U", + "typ": "Youtube" + }, + "SADBOY - Blizgantys Naikai": { + "url": "https://www.youtube.com/watch?v=p5KsYJGcfOM", + "typ": "Youtube" + }, + "Dzordana Butkute - Nebenoriu Laukt": { + "url": "https://www.youtube.com/watch?v=_AozFrAqNMk", + "typ": "Youtube" + }, + "Ciulpuoneliai - Jau Nutilo Sirgaliai": { + "url": "https://www.youtube.com/watch?v=s8qIVA1U0C0", + "typ": "Youtube" + }, + "Robertas Kupstas - Cia Mano Rojus": { + "url": "https://www.youtube.com/watch?v=xij_YeEInr8", + "typ": "Youtube" + }, + "Depresinis feat. Deivas - 0,7": { + "url": "https://www.youtube.com/watch?v=rjwFjBgTzAA", + "typ": "Youtube" + }, + "Radvis - TU ESI MELAGIS (Techno Extended)": { + "url": "https://www.youtube.com/watch?v=kmvvP7GW_bw", + "typ": "Youtube" + }, + "Depresinis feat. Deivas - Pavasaris": { + "url": "https://www.youtube.com/watch?v=yWWAucfQdN4", + "typ": "Youtube" + }, + "DJ Dalgis - Negeriau": { + "url": "https://www.youtube.com/watch?v=c89YvG3MCcs", + "typ": "Youtube" + }, + "Jovani, Karaliska Erdve - Is Leto Leidziasi Saule": { + "url": "https://www.youtube.com/watch?v=VqSu8iG1_DE", + "typ": "Youtube" + }, + "Funky - Be taves": { + "url": "https://www.youtube.com/watch?v=heTDrDukLWU", + "typ": "Youtube" + }, + "Vitalija Katunskyte - Robinzonas": { + "url": "https://www.youtube.com/watch?v=erDHG-QpbPY", + "typ": "Youtube" + }, + "Tipo grupe ir Kastaneda - Po stikliuka": { + "url": "https://www.youtube.com/watch?v=EtmE60nE7fI", + "typ": "Youtube" + }, + "Zas - Zalias Pasas": { + "url": "https://www.youtube.com/watch?v=SZA7IjlCfyI", + "typ": "Youtube" + }, + "Mercy Dance - I Pajuri": { + "url": "https://www.youtube.com/watch?v=RPpkMh47l9w", + "typ": "Youtube" + }, + "NL - R1": { + "url": "https://www.youtube.com/watch?v=hSgav4fYnZ8", + "typ": "Youtube" + }, + "Raketa - I Kluba": { + "url": "https://www.youtube.com/watch?v=FkSjtpYN3EI", + "typ": "Youtube" + }, + "MC ENDRAY - AUDI": { + "url": "https://www.youtube.com/watch?v=oIjNoMGEuRg", + "typ": "Youtube" + }, + "Rondo - Margarita": { + "url": "https://www.youtube.com/watch?v=rF4w-Rxsiv4", + "typ": "Youtube" + }, + "Wenona Waves - Topine Panele": { + "url": "https://www.youtube.com/watch?v=MPHuhmUomfE", + "typ": "Youtube" + }, + "SixthBoi - Nevaidink": { + "url": "https://www.youtube.com/watch?v=nOTNnnrqTII", + "typ": "Youtube" + }, + "Adomas Vysniauskas - As Judu": { + "url": "https://www.youtube.com/watch?v=dMm16TzZrjg", + "typ": "Youtube" + }, + "Nezinau, Kodel...": { + "url": "https://www.youtube.com/watch?v=A-i2CkCnPoc", + "typ": "Youtube" + }, + "Ka Tu Ka Vakare": { + "url": "https://www.youtube.com/watch?v=6SOS4ljHbJY", + "typ": "Youtube" + }, + "MG INTERNATIONAL - JUODA ORCHIDEJA": { + "url": "https://www.youtube.com/watch?v=HQvceFRBq9M", + "typ": "Youtube" + }, + "Deivas - Klaipeda On Top": { + "url": "https://www.youtube.com/watch?v=g_h2M3e2OYU", + "typ": "Youtube" + }, + "VAIKAI PO LELIJOM (REMIX)": { + "url": "https://www.youtube.com/watch?v=k1amBbsAZuo", + "typ": "Youtube" + }, + "Kastanenda - Sombrero": { + "url": "https://www.youtube.com/watch?v=3Z3_4TknCfQ", + "typ": "Youtube" + }, + "Rytis Cicinas - Ne, nereikia asaru": { + "url": "https://www.youtube.com/watch?v=48GSg1q2kPE", + "typ": "Youtube" + }, + "Depresinis, Jypas - O Mazuti": { + "url": "https://www.youtube.com/watch?v=4t_DPbe2r3M", + "typ": "Youtube" + }, + "SADBOY - Deginam": { + "url": "https://www.youtube.com/watch?v=w3R0Aq1EGXg", + "typ": "Youtube" + }, + "Zilviokas - Ryk Zuvedra ryk": { + "url": "https://www.youtube.com/watch?v=eN6BOI7UlSE", + "typ": "Youtube" + }, + "69 Danguje - 16 metu": { + "url": "https://www.youtube.com/watch?v=nwjoqPcUPrw", + "typ": "Youtube" + }, + "morre - Kaip Diena": { + "url": "https://www.youtube.com/watch?v=6LDgLWCQSSM", + "typ": "Youtube" + }, + "Tipo grupe - Lovoj Vezi": { + "url": "https://www.youtube.com/watch?v=M3zVMzWCy_c", + "typ": "Youtube" + }, + "Eugenijus Ostapenko - Dviratukas": { + "url": "https://www.youtube.com/watch?v=ILFHZQK33Mw", + "typ": "Youtube" + }, + "Grupiokai - Degtine": { + "url": "https://www.youtube.com/watch?v=8SqbG2VmEFw", + "typ": "Youtube" + }, + "SADBOY - Kaifuok": { + "url": "https://www.youtube.com/watch?v=vclryWgfy8I", + "typ": "Youtube" + }, + "Andzikas - I gamta": { + "url": "https://www.youtube.com/watch?v=UyLdjC-hihM", + "typ": "Youtube" + }, + "MAMA MANE RODYS PER FARUS": { + "url": "https://www.youtube.com/watch?v=F5HqXYRDZaE", + "typ": "Youtube" + }, + "Patruliai - Kur Tu": { + "url": "https://www.youtube.com/watch?v=OPWhiu3cvj0", + "typ": "Youtube" + }, + "Karaliska Erdve - Vakareja": { + "url": "https://www.youtube.com/watch?v=g0HmrlJ7fhE", + "typ": "Youtube" + }, + "Rycka klipas": { + "url": "https://www.youtube.com/watch?v=nuTUDSQ3BBI", + "typ": "Youtube" + }, + "Zas - Myliu kina": { + "url": "https://www.youtube.com/watch?v=ImFrfmi-qT8", + "typ": "Youtube" + }, + "16Hz - Baliavojam": { + "url": "https://www.youtube.com/watch?v=Ia-qERX8WLs", + "typ": "Youtube" + }, + "Vilija ir Marijonas mikutavicius - Dabar Geriausi Musu Vakarai": { + "url": "https://www.youtube.com/watch?v=MPnZkEscWo0", + "typ": "Youtube" + }, + "Dove - Naktinis Tusas": { + "url": "https://www.youtube.com/watch?v=pz-HEAwFEnk", + "typ": "Youtube" + }, + "Tweaxx - Mersas": { + "url": "https://www.youtube.com/watch?v=7ljAzgALPdA", + "typ": "Youtube" + }, + "Andzikas - Virs debesu": { + "url": "https://www.youtube.com/watch?v=PHJcVGhxra8", + "typ": "Youtube" + }, + "Parnesk alaus OG": { + "url": "https://www.youtube.com/watch?v=e7cB1JIlZ2k", + "typ": "Youtube" + }, + "Vytautas siskauskas - Lietuva (Nebelinksmas musu kaimas)": { + "url": "https://www.youtube.com/watch?v=31UkGzde14c", + "typ": "Youtube" + }, + "NIERKA - PENKTADIENIS": { + "url": "https://www.youtube.com/watch?v=h3TuZj_OAf0", + "typ": "Youtube" + }, + "SADBOY - 1001 Naktis": { + "url": "https://www.youtube.com/watch?v=mLJIjGvWmKI", + "typ": "Youtube" + }, + "RADVIS - KINO FILMAI": { + "url": "https://www.youtube.com/watch?v=vhAEkC3xNMo", + "typ": "Youtube" + }, + "Ganja - Truputi": { + "url": "https://www.youtube.com/watch?v=Pxve7CwiCHM", + "typ": "Youtube" + }, + "DJ Dalgis - Kauniete": { + "url": "https://www.youtube.com/watch?v=b3xPE9Iyuzc", + "typ": "Youtube" + }, + "Kastaneda - Kelyje": { + "url": "https://www.youtube.com/watch?v=JVE6NQqKPL4", + "typ": "Youtube" + }, + "Tipo Grupe - tipo daina": { + "url": "https://www.youtube.com/watch?v=PTIOaSjEgIU", + "typ": "Youtube" + }, + "16Hz - Autostrada Vilnius - Kaunas": { + "url": "https://www.youtube.com/watch?v=ANS2TSegr40", + "typ": "Youtube" + }, + "Depresinis feat. Deivas - LEDUKAI": { + "url": "https://www.youtube.com/watch?v=R2-MtpkKgGI", + "typ": "Youtube" + }, + "Vairas - Svajoklis": { + "url": "https://www.youtube.com/watch?v=hs8_KTV0Vrw", + "typ": "Youtube" + }, + "Riaukenzo - Trys Trys Trys": { + "url": "https://www.youtube.com/watch?v=qJv6GRQCnCk", + "typ": "Youtube" + }, + "L1GHT CASH - Whiskey Cola Lietuviskai (sultys degtinele) remix": { + "url": "https://www.youtube.com/watch?v=YVaqDaf1KXU", + "typ": "Youtube" + }, + "Vaidas Baumila - Apzavai": { + "url": "https://www.youtube.com/watch?v=H8uGi4ZMgHA", + "typ": "Youtube" + }, + "DJ Dalgis - Zalia Siera": { + "url": "https://www.youtube.com/watch?v=nfentq_pez4", + "typ": "Youtube" + }, + "Depresinis & MERAKI2004 - VASARA ZJBS": { + "url": "https://www.youtube.com/watch?v=BD-pBjRy-5A", + "typ": "Youtube" + }, + "nemuno krantai - rytmecio rasos": { + "url": "https://www.youtube.com/watch?v=2-fGbsrofv4", + "typ": "Youtube" + }, + "PROFLAME - biznis": { + "url": "https://www.youtube.com/watch?v=t139Vd83pgs", + "typ": "Youtube" + } + } + }, + "techno": { + "songs": { + "$UICIDEBOY$ - PARIS (TECHNO)": { + "url": "https://www.youtube.com/watch?v=YYDJmGDkEyw", + "typ": "Youtube" + }, + "Give It To Me": { + "url": "https://www.youtube.com/watch?v=upQe8EeSyZU", + "typ": "Youtube" + }, + "The Love Parade ( Bounce Invaderz )": { + "url": "https://www.youtube.com/watch?v=xogT6KBWjCU3", + "typ": "Youtube" + }, + "08 Blumchen - Blaue Augen": { + "url": "https://www.youtube.com/watch?v=mE4PZcUfiwE", + "typ": "Youtube" + }, + "Raffaella Carra - Pedro (Jaxomy & Agatino Romero Remix)": { + "url": "https://www.youtube.com/watch?v=AIGnRc7F86Q", + "typ": "Youtube" + }, + "MUTA - Party maker": { + "url": "https://www.youtube.com/watch?v=LT9VNK1aCXY", + "typ": "Youtube" + }, + "Beggin' (Techno)": { + "url": "https://www.youtube.com/watch?v=tXPs1FwW6lk", + "typ": "Youtube" + }, + "Restricted - Big Jet Plane": { + "url": "https://www.youtube.com/watch?v=NpVF0z5N-tE", + "typ": "Youtube" + }, + "Lily Allen - Not Fair": { + "url": "https://www.youtube.com/watch?v=WON_YIbeLis", + "typ": "Youtube" + }, + "Dance For Me": { + "url": "https://www.youtube.com/watch?v=5DTSvGO_944", + "typ": "Youtube" + }, + "I WAS MADE FOR LOVIN' YOU (TECHNO)": { + "url": "https://www.youtube.com/watch?v=asVznhccYao", + "typ": "Youtube" + }, + "Empire Of The Sun, southstar - We Are The People": { + "url": "https://www.youtube.com/watch?v=qguEGR5BK2k", + "typ": "Youtube" + }, + "Nicolas Julian - Applause": { + "url": "https://www.youtube.com/watch?v=9qHLELnq1B0", + "typ": "Youtube" + }, + "Knock2 - dashstar": { + "url": "https://www.youtube.com/watch?v=58ml5b_On6w", + "typ": "Youtube" + }, + "Gigi D'Agostino - Bla Bla Bla": { + "url": "https://www.youtube.com/watch?v=yKapqR2XRJE", + "typ": "Youtube" + }, + "Manian - Welcome To The Club": { + "url": "https://www.youtube.com/watch?v=7F9xDewtgNA", + "typ": "Youtube" + } + } + }, + "rock": { + "songs": { + "Black Sabbath": { + "url": "https://www.youtube.com/watch?v=BOTIIw76qiE", "typ": "Youtube" } } @@ -159,24 +619,16 @@ "url": "https://www.youtube.com/watch?v=XhyM-JUWwWQ", "typ": "Youtube" }, - "Bauhouse - After Marvins Dance (Marvin Gaye's 'After The Dance' Edit)": { - "url": "https://www.youtube.com/watch?v=J-cgyYiExh8", - "typ": "Youtube" - }, - "Sweely - Le Son Dancefloor": { - "url": "https://www.youtube.com/watch?v=5uEvZgmoG6Y", - "typ": "Youtube" - }, "THEOS - Rhodes Trip": { "url": "https://www.youtube.com/watch?v=m7guRO0Uz_c", "typ": "Youtube" }, - "Unknown Artist - Kcik 23": { - "url": "https://www.youtube.com/watch?v=SnnqDdZJpzA", + "Baltra - Tears Drop": { + "url": "https://www.youtube.com/watch?v=EXXMtKPfuzY", "typ": "Youtube" }, - "Billie Eilish - Bossa Nova (Lewii Edit)": { - "url": "https://www.youtube.com/watch?v=gNawHj2NCxA", + "Bauhouse - After Marvins Dance (Marvin Gaye's 'After The Dance' Edit)": { + "url": "https://www.youtube.com/watch?v=J-cgyYiExh8", "typ": "Youtube" }, "Fidde - I Only See Things I Dont Have": { @@ -187,94 +639,26 @@ "url": "https://www.youtube.com/watch?v=l2Nw7cIh7qg", "typ": "Youtube" }, - "Baltra - Tears Drop": { - "url": "https://www.youtube.com/watch?v=EXXMtKPfuzY", - "typ": "Youtube" - } - } - }, - "hip-hop": { - "songs": { - "Afroman - Because I Got High": { - "url": "https://www.youtube.com/watch?v=WeYsTmIzjkw", + "Unknown Artist - Kcik 23": { + "url": "https://www.youtube.com/watch?v=SnnqDdZJpzA", "typ": "Youtube" }, - "Drenchill - Freed from Desire": { - "url": "https://www.youtube.com/watch?v=6b6FBneAENQ", - "typ": "Youtube" - } - } - }, - "techno": { - "songs": { - "Give It To Me": { - "url": "https://www.youtube.com/watch?v=upQe8EeSyZU", + "Sweely - Le Son Dancefloor": { + "url": "https://www.youtube.com/watch?v=5uEvZgmoG6Y", "typ": "Youtube" }, - "MUTA - Party maker": { - "url": "https://www.youtube.com/watch?v=LT9VNK1aCXY", - "typ": "Youtube" - }, - "Raffaella Carra - Pedro (Jaxomy & Agatino Romero Remix)": { - "url": "https://www.youtube.com/watch?v=AIGnRc7F86Q", - "typ": "Youtube" - }, - "I WAS MADE FOR LOVIN' YOU (TECHNO)": { - "url": "https://www.youtube.com/watch?v=asVznhccYao", - "typ": "Youtube" - }, - "Empire Of The Sun, southstar - We Are The People": { - "url": "https://www.youtube.com/watch?v=qguEGR5BK2k", - "typ": "Youtube" - }, - "The Love Parade ( Bounce Invaderz )": { - "url": "https://www.youtube.com/watch?v=xogT6KBWjCU3", - "typ": "Youtube" - }, - "Manian - Welcome To The Club": { - "url": "https://www.youtube.com/watch?v=7F9xDewtgNA", - "typ": "Youtube" - }, - "Restricted - Big Jet Plane": { - "url": "https://www.youtube.com/watch?v=NpVF0z5N-tE", - "typ": "Youtube" - }, - "$UICIDEBOY$ - PARIS (TECHNO)": { - "url": "https://www.youtube.com/watch?v=YYDJmGDkEyw", - "typ": "Youtube" - }, - "Gigi D'Agostino - Bla Bla Bla": { - "url": "https://www.youtube.com/watch?v=yKapqR2XRJE", - "typ": "Youtube" - }, - "Nicolas Julian - Applause": { - "url": "https://www.youtube.com/watch?v=9qHLELnq1B0", - "typ": "Youtube" - }, - "08 Blumchen - Blaue Augen": { - "url": "https://www.youtube.com/watch?v=mE4PZcUfiwE", - "typ": "Youtube" - }, - "Lily Allen - Not Fair": { - "url": "https://www.youtube.com/watch?v=WON_YIbeLis", - "typ": "Youtube" - }, - "Knock2 - dashstar": { - "url": "https://www.youtube.com/watch?v=58ml5b_On6w", - "typ": "Youtube" - }, - "Beggin' (Techno)": { - "url": "https://www.youtube.com/watch?v=tXPs1FwW6lk", - "typ": "Youtube" - }, - "Dance For Me": { - "url": "https://www.youtube.com/watch?v=5DTSvGO_944", + "Billie Eilish - Bossa Nova (Lewii Edit)": { + "url": "https://www.youtube.com/watch?v=gNawHj2NCxA", "typ": "Youtube" } } }, "noclue": { "songs": { + "Discobitch - C'est Beau La Bourgeoisie": { + "url": "https://www.youtube.com/watch?v=RCeQN2aEWxo", + "typ": "Youtube" + }, "Maco Mamuko - Whiskey, Cola i Tequila": { "url": "https://www.youtube.com/watch?v=aBrN0k0Phtc", "typ": "Youtube" @@ -283,395 +667,11 @@ "url": "https://www.youtube.com/watch?v=HLbw1WQt64o", "typ": "Youtube" }, - "Discobitch - C'est Beau La Bourgeoisie": { - "url": "https://www.youtube.com/watch?v=RCeQN2aEWxo", - "typ": "Youtube" - }, "Bad Boys": { "url": "https://www.youtube.com/watch?v=NTC7RD8xzCY", "typ": "Youtube" } } - }, - "lietuviskos": { - "songs": { - "16Hz - Autostrada Vilnius - Kaunas": { - "url": "https://www.youtube.com/watch?v=ANS2TSegr40", - "typ": "Youtube" - }, - "Dzordana Butkute - Nebenoriu Laukt": { - "url": "https://www.youtube.com/watch?v=_AozFrAqNMk", - "typ": "Youtube" - }, - "PROFLAME - biznis": { - "url": "https://www.youtube.com/watch?v=t139Vd83pgs", - "typ": "Youtube" - }, - "Patruliai - Kur Tu": { - "url": "https://www.youtube.com/watch?v=OPWhiu3cvj0", - "typ": "Youtube" - }, - "Ganja - Truputi": { - "url": "https://www.youtube.com/watch?v=Pxve7CwiCHM", - "typ": "Youtube" - }, - "SADBOY - Kaifuok": { - "url": "https://www.youtube.com/watch?v=vclryWgfy8I", - "typ": "Youtube" - }, - "Depresinis - LEDINE": { - "url": "https://www.youtube.com/watch?v=qugvChkXMLk", - "typ": "Youtube" - }, - "MAMA MANE RODYS PER FARUS": { - "url": "https://www.youtube.com/watch?v=F5HqXYRDZaE", - "typ": "Youtube" - }, - "SADBOY - Blizgantys Naikai": { - "url": "https://www.youtube.com/watch?v=p5KsYJGcfOM", - "typ": "Youtube" - }, - "16Hz - Baliavojam": { - "url": "https://www.youtube.com/watch?v=Ia-qERX8WLs", - "typ": "Youtube" - }, - "RADVIS - KINO FILMAI": { - "url": "https://www.youtube.com/watch?v=vhAEkC3xNMo", - "typ": "Youtube" - }, - "Grupe MX - 1.9 TDI": { - "url": "https://www.youtube.com/watch?v=8FBr5GQXsI8", - "typ": "Youtube" - }, - "Depresinis feat. Deivas - LEDUKAI": { - "url": "https://www.youtube.com/watch?v=R2-MtpkKgGI", - "typ": "Youtube" - }, - "Kastaneda - Kelyje": { - "url": "https://www.youtube.com/watch?v=JVE6NQqKPL4", - "typ": "Youtube" - }, - "69 Danguje - Gyvenu": { - "url": "https://www.youtube.com/watch?v=HMXlhmAoux4", - "typ": "Youtube" - }, - "Vitalija Katunskyte - Robinzonas": { - "url": "https://www.youtube.com/watch?v=erDHG-QpbPY", - "typ": "Youtube" - }, - "DJ Dalgis - Kauniete": { - "url": "https://www.youtube.com/watch?v=b3xPE9Iyuzc", - "typ": "Youtube" - }, - "NL - Juodas Golfas": { - "url": "https://www.youtube.com/watch?v=f2-ZmElSvPc", - "typ": "Youtube" - }, - "Depresinis, Jypas - O Mazuti": { - "url": "https://www.youtube.com/watch?v=4t_DPbe2r3M", - "typ": "Youtube" - }, - "Zas - Myliu kina": { - "url": "https://www.youtube.com/watch?v=ImFrfmi-qT8", - "typ": "Youtube" - }, - "Adomas Vysniauskas - As Judu": { - "url": "https://www.youtube.com/watch?v=dMm16TzZrjg", - "typ": "Youtube" - }, - "Tipo grupe ir Kastaneda - Po stikliuka": { - "url": "https://www.youtube.com/watch?v=EtmE60nE7fI", - "typ": "Youtube" - }, - "SADBOY - 1001 Naktis": { - "url": "https://www.youtube.com/watch?v=mLJIjGvWmKI", - "typ": "Youtube" - }, - "Rondo - Margarita": { - "url": "https://www.youtube.com/watch?v=rF4w-Rxsiv4", - "typ": "Youtube" - }, - "Zas - Zalias Pasas": { - "url": "https://www.youtube.com/watch?v=SZA7IjlCfyI", - "typ": "Youtube" - }, - "Tweaxx - Mersas": { - "url": "https://www.youtube.com/watch?v=7ljAzgALPdA", - "typ": "Youtube" - }, - "morre - Kaip Diena": { - "url": "https://www.youtube.com/watch?v=6LDgLWCQSSM", - "typ": "Youtube" - }, - "L1GHT CASH - Whiskey Cola Lietuviskai (sultys degtinele) remix": { - "url": "https://www.youtube.com/watch?v=YVaqDaf1KXU", - "typ": "Youtube" - }, - "NL - R1": { - "url": "https://www.youtube.com/watch?v=hSgav4fYnZ8", - "typ": "Youtube" - }, - "Juodas Garvezys (Remix)": { - "url": "https://www.youtube.com/watch?v=D-7qQbXHSAw", - "typ": "Youtube" - }, - "Rycka klipas": { - "url": "https://www.youtube.com/watch?v=nuTUDSQ3BBI", - "typ": "Youtube" - }, - "Riaukenzo - Trys Trys Trys": { - "url": "https://www.youtube.com/watch?v=qJv6GRQCnCk", - "typ": "Youtube" - }, - "Karaliska Erdve - Vakareja": { - "url": "https://www.youtube.com/watch?v=g0HmrlJ7fhE", - "typ": "Youtube" - }, - "Judam Lietuvoj": { - "url": "https://www.youtube.com/watch?v=WDzWSEgSy5U", - "typ": "Youtube" - }, - "Eugenijus Ostapenko - Dviratukas": { - "url": "https://www.youtube.com/watch?v=ILFHZQK33Mw", - "typ": "Youtube" - }, - "Wenona Waves - Topine Panele": { - "url": "https://www.youtube.com/watch?v=MPHuhmUomfE", - "typ": "Youtube" - }, - "SixthBoi - Nevaidink": { - "url": "https://www.youtube.com/watch?v=nOTNnnrqTII", - "typ": "Youtube" - }, - "NL - Pasitusinam": { - "url": "https://www.youtube.com/watch?v=WhSFudvloog", - "typ": "Youtube" - }, - "Jovani, Karaliska Erdve - Is Leto Leidziasi Saule": { - "url": "https://www.youtube.com/watch?v=VqSu8iG1_DE", - "typ": "Youtube" - }, - "Nezinau, Kodel...": { - "url": "https://www.youtube.com/watch?v=A-i2CkCnPoc", - "typ": "Youtube" - }, - "Funky - Be taves": { - "url": "https://www.youtube.com/watch?v=heTDrDukLWU", - "typ": "Youtube" - }, - "Kastanenda - Sombrero": { - "url": "https://www.youtube.com/watch?v=3Z3_4TknCfQ", - "typ": "Youtube" - }, - "Elektra - Juda Tavo rankos": { - "url": "https://www.youtube.com/watch?v=k2RuDoudnOE", - "typ": "Youtube" - }, - "Vairas - Svajoklis": { - "url": "https://www.youtube.com/watch?v=hs8_KTV0Vrw", - "typ": "Youtube" - }, - "Robertas Kupstas - Cia Mano Rojus": { - "url": "https://www.youtube.com/watch?v=xij_YeEInr8", - "typ": "Youtube" - }, - "Depresinis feat. Deivas - 0,7": { - "url": "https://www.youtube.com/watch?v=rjwFjBgTzAA", - "typ": "Youtube" - }, - "VAIKAI PO LELIJOM (REMIX)": { - "url": "https://www.youtube.com/watch?v=k1amBbsAZuo", - "typ": "Youtube" - }, - "SADBOY - Deginam": { - "url": "https://www.youtube.com/watch?v=w3R0Aq1EGXg", - "typ": "Youtube" - }, - "Rytis Cicinas - Ne, nereikia asaru": { - "url": "https://www.youtube.com/watch?v=48GSg1q2kPE", - "typ": "Youtube" - }, - "nemuno krantai - rytmecio rasos": { - "url": "https://www.youtube.com/watch?v=2-fGbsrofv4", - "typ": "Youtube" - }, - "MC ENDRAY - AUDI": { - "url": "https://www.youtube.com/watch?v=oIjNoMGEuRg", - "typ": "Youtube" - }, - "Vilija ir Marijonas mikutavicius - Dabar Geriausi Musu Vakarai": { - "url": "https://www.youtube.com/watch?v=MPnZkEscWo0", - "typ": "Youtube" - }, - "Andzikas - Virs debesu": { - "url": "https://www.youtube.com/watch?v=PHJcVGhxra8", - "typ": "Youtube" - }, - "Deivas - Klaipeda On Top": { - "url": "https://www.youtube.com/watch?v=g_h2M3e2OYU", - "typ": "Youtube" - }, - "Tipo grupe - Lovoj Vezi": { - "url": "https://www.youtube.com/watch?v=M3zVMzWCy_c", - "typ": "Youtube" - }, - "Radvis - TU ESI MELAGIS (Techno Extended)": { - "url": "https://www.youtube.com/watch?v=kmvvP7GW_bw", - "typ": "Youtube" - }, - "Depresinis feat. Deivas - Pavasaris": { - "url": "https://www.youtube.com/watch?v=yWWAucfQdN4", - "typ": "Youtube" - }, - "Mercy Dance - I Pajuri": { - "url": "https://www.youtube.com/watch?v=RPpkMh47l9w", - "typ": "Youtube" - }, - "Ka Tu Ka Vakare": { - "url": "https://www.youtube.com/watch?v=6SOS4ljHbJY", - "typ": "Youtube" - }, - "Mr.Bullet - UZ MUS IR JUS": { - "url": "https://www.youtube.com/watch?v=85q_7jXEgH8", - "typ": "Youtube" - }, - "NIERKA - PENKTADIENIS": { - "url": "https://www.youtube.com/watch?v=h3TuZj_OAf0", - "typ": "Youtube" - }, - "MG INTERNATIONAL - JUODA ORCHIDEJA": { - "url": "https://www.youtube.com/watch?v=HQvceFRBq9M", - "typ": "Youtube" - }, - "Raketa - I Kluba": { - "url": "https://www.youtube.com/watch?v=FkSjtpYN3EI", - "typ": "Youtube" - }, - "AVA - Eik Tu NA": { - "url": "https://www.youtube.com/watch?v=yRf3ijaIgOg", - "typ": "Youtube" - }, - "69 Danguje - 16 metu": { - "url": "https://www.youtube.com/watch?v=nwjoqPcUPrw", - "typ": "Youtube" - }, - "Vytautas siskauskas - Lietuva (Nebelinksmas musu kaimas)": { - "url": "https://www.youtube.com/watch?v=31UkGzde14c", - "typ": "Youtube" - }, - "Zilvinas Zvagulis - Amerikonas grizo sunus": { - "url": "https://www.youtube.com/watch?v=UvzJEz5ADY8", - "typ": "Youtube" - }, - "Tipo Grupe - tipo daina": { - "url": "https://www.youtube.com/watch?v=PTIOaSjEgIU", - "typ": "Youtube" - }, - "Ciulpuoneliai - Jau Nutilo Sirgaliai": { - "url": "https://www.youtube.com/watch?v=s8qIVA1U0C0", - "typ": "Youtube" - }, - "Grupiokai - Degtine": { - "url": "https://www.youtube.com/watch?v=8SqbG2VmEFw", - "typ": "Youtube" - }, - "Depresinis & MERAKI2004 - VASARA ZJBS": { - "url": "https://www.youtube.com/watch?v=BD-pBjRy-5A", - "typ": "Youtube" - }, - "Vaidas Baumila - Apzavai": { - "url": "https://www.youtube.com/watch?v=H8uGi4ZMgHA", - "typ": "Youtube" - }, - "Parnesk alaus OG": { - "url": "https://www.youtube.com/watch?v=e7cB1JIlZ2k", - "typ": "Youtube" - }, - "Tnn - Parukom": { - "url": "https://www.youtube.com/watch?v=v9pBZK2RIPI", - "typ": "Youtube" - }, - "DJ Dalgis - Negeriau": { - "url": "https://www.youtube.com/watch?v=c89YvG3MCcs", - "typ": "Youtube" - }, - "Dove - Naktinis Tusas": { - "url": "https://www.youtube.com/watch?v=pz-HEAwFEnk", - "typ": "Youtube" - }, - "Depresinis - Volkswagina": { - "url": "https://www.youtube.com/watch?v=1lZR1VKsQHo", - "typ": "Youtube" - }, - "Zilviokas - Ryk Zuvedra ryk": { - "url": "https://www.youtube.com/watch?v=eN6BOI7UlSE", - "typ": "Youtube" - }, - "DJ Dalgis - Zalia Siera": { - "url": "https://www.youtube.com/watch?v=nfentq_pez4", - "typ": "Youtube" - }, - "Andzikas - I gamta": { - "url": "https://www.youtube.com/watch?v=UyLdjC-hihM", - "typ": "Youtube" - } - } - }, - "rock": { - "songs": { - "Black Sabbath": { - "url": "https://www.youtube.com/watch?v=BOTIIw76qiE", - "typ": "Youtube" - } - } - }, - "lietuviskos/sel": { - "songs": { - "SEL - As ziuriu i tave pasauli": { - "url": "https://youtu.be/_SPDjl80kKw", - "typ": "Youtube" - }, - "SEL - Ten kur sapnai": { - "url": "https://youtu.be/GDj3NgjDbRo", - "typ": "Youtube" - }, - "SEL - Gyvenimo man vieno neuztenka": { - "url": "https://youtu.be/7Gd9XaEG5o4", - "typ": "Youtube" - }, - "SEL - Ten kazkur giliai": { - "url": "https://youtu.be/N7YNlegeiqs?si=9BBH6hjrgOjJ01Nz", - "typ": "Youtube" - }, - "SEL - Lyja": { - "url": "https://www.youtube.com/watch?v=KL6JBWnXCxw", - "typ": "Youtube" - }, - "SEL - Skrendu": { - "url": "https://youtu.be/G5Q_asvrXlA", - "typ": "Youtube" - }, - "SEL - Nes as tik vejas": { - "url": "https://youtu.be/acMG37IZ6z8", - "typ": "Youtube" - }, - "SEL - Tarp amzinybes": { - "url": "https://youtu.be/UfPj-0QpGFA", - "typ": "Youtube" - }, - "SEL - Tik Tok": { - "url": "https://youtu.be/RkaIUateIxg", - "typ": "Youtube" - }, - "SEL - Leisk": { - "url": "https://youtu.be/DDPmFMrffXQ", - "typ": "Youtube" - }, - "SEL - Uzmerkiu akis": { - "url": "https://youtu.be/SdWj06XRZms?si=9TNGzjK9ITom-jaD", - "typ": "Youtube" - } - } } } -} \ No newline at end of file +} diff --git a/src/commands/add.rs b/src/commands/add.rs index 94ad653..4ee9fb5 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -1,42 +1,26 @@ use std::str::FromStr; +use anyhow::bail; + use crate::{config::ConfigWrapper, downloader::Downloader, manifest::{song::Song, Manifest}, util::is_supported_host}; -pub async fn add(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &Option, name: &Option, playlist: &Option) -> anyhow::Result<()> { +pub async fn add(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &String, name: &String, playlist: &String) -> anyhow::Result<()> { - log::debug!("Playlist: {playlist:?}"); - log::debug!("url: {url:?}"); - log::debug!("name: {name:?}"); - let mut playlists = manifest.get_playlists().keys().map(|f| f.clone()).collect::>(); playlists.sort(); - let playlist = playlist.clone().unwrap_or_else( || { - let g = crate::prompt::prompt_with_list_or_str("Enter song playlist", &playlists); - log::info!("Playlist: {g}"); - g - }); - - - let url = url.clone().unwrap_or_else( || - crate::prompt::simple_prompt("Enter song youtube url, make sure its not a playlist, (yt only for now)") - ); - if !is_supported_host(url::Url::from_str(&url)?) { log::error!("Invalid or unsupported host name"); return Ok(()); } - let name = name.clone().unwrap_or_else( || - crate::prompt::simple_prompt("Enter song name with like this: {Author} - {Song name}") - ); - let song = Song::from_url_str(url)?; - manifest.add_song(playlist.clone(), name.clone(), song.clone()); + let song = Song::from_url_str(url.clone())?; + manifest.add_song(playlist, name.clone(), song.clone()); manifest.save(None)?; let should_download = crate::prompt::prompt_bool("Download song now?", Some(false)); @@ -48,3 +32,24 @@ pub async fn add(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Ok(()) } + +pub async fn add_playlist(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &String, name: &String) -> anyhow::Result<()> { + let songs = downloader.download_playlist_nb(cfg, url, name, manifest.get_format())?; + + if manifest.get_playlist(name).is_some() { + log::error!("Playlist {name} already exists"); + bail!("") + } + + manifest.add_playlist(name.clone()); + + let playlist = manifest.get_playlist_mut(name).expect("Unreachable"); + + for (sname, song) in songs { + playlist.add_song(sname, song); + } + manifest.save(None)?; + + while downloader.download_all_nb_poll(cfg)?.is_some() {}; + Ok(()) +} diff --git a/src/commands/gui/song_edit_window.rs b/src/commands/gui/song_edit_window.rs index a51212d..b23e03a 100644 --- a/src/commands/gui/song_edit_window.rs +++ b/src/commands/gui/song_edit_window.rs @@ -24,7 +24,7 @@ impl Gui { let (playlist, song_name) = self.song_editor.song.clone(); - let Some(song) = self.manifest.get_song(playlist.clone(), &song_name) else { + let Some(song) = self.manifest.get_song(&playlist, &song_name) else { return; }; let song = song.clone(); @@ -65,14 +65,14 @@ impl Gui { if save { { - let Some(song) = self.manifest.get_song_mut(playlist.clone(), &song_name) else { + let Some(song) = self.manifest.get_song_mut(&playlist, &song_name) else { return; }; *song.get_url_str_mut() = self.song_editor.ed_url.clone(); } - let Some(playlist) = self.manifest.get_playlist_mut(playlist.clone()) else { + let Some(playlist) = self.manifest.get_playlist_mut(&playlist) else { return; }; @@ -126,7 +126,7 @@ impl Gui { }); if save { - let Some(playlist) = self.manifest.get_playlist_mut(self.song_editor.ed_playlist.clone().unwrap()) else { + let Some(playlist) = self.manifest.get_playlist_mut(&self.song_editor.ed_playlist.clone().unwrap()) else { panic!("couldnt find playlist from a preset playlist list????????????"); }; @@ -137,7 +137,6 @@ impl Gui { let _ = self.manifest.save(None); - save = false; self.song_editor.is_new_open = false; } } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 9e0dac4..4101391 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -23,6 +23,11 @@ pub async fn command_run(cfg: &ConfigWrapper, manifest: &mut Manifest) -> anyhow (Some(c), _) => { match c { CliCommand::Download => unreachable!(), + CliCommand::AddPlaylist { url, name } => { + if let Err(e) = add::add_playlist(cfg, manifest, &mut downloader, url, name).await { + log::error!("Failed to run 'add-playlist' commmand: {e}"); + } + } CliCommand::Add { url, name, playlist } => { if let Err(e) = add::add(cfg, manifest, &mut downloader, url, name, playlist).await { log::error!("Failed to run 'add' command: {e}"); diff --git a/src/config/cli.rs b/src/config/cli.rs index 4683a28..4dd884e 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -30,11 +30,17 @@ pub enum CliCommand { Download, Add { #[arg(long, short)] - url: Option, + url: String, #[arg(long, short)] - name: Option, + name: String, #[arg(long, short)] - playlist: Option + playlist: String + }, + AddPlaylist { + #[arg(long, short)] + url: String, + #[arg(long, short)] + name: String }, Gui } diff --git a/src/downloader.rs b/src/downloader.rs index 80639f0..1640a0a 100644 --- a/src/downloader.rs +++ b/src/downloader.rs @@ -40,7 +40,7 @@ impl Downloader { self.nb_cache.len() } - pub fn download_all_nb(&mut self, manifest: &Manifest, cfg: &ConfigWrapper) -> anyhow::Result { + pub fn download_all_nb(&mut self, manifest: &Manifest, cfg: &ConfigWrapper) -> anyhow::Result> { for (pname, playlist) in manifest.get_playlists() { for (sname, song) in playlist.get_songs() { self.nb_cache.push((pname.clone(), sname.clone(), song.clone(), manifest.get_format().clone())); @@ -51,14 +51,20 @@ impl Downloader { self.download_all_nb_poll(cfg) } - pub fn download_all_nb_poll(&mut self, cfg: &ConfigWrapper) -> anyhow::Result { + pub fn download_all_nb_poll(&mut self, cfg: &ConfigWrapper) -> anyhow::Result> { if !crate::process_manager::is_proc_queue_full(10) { if let Some((pname, sname, song, format)) = self.nb_cache.pop() { self.download_song(cfg, &sname, &song, &pname, &format)?; } } - - Ok(crate::process_manager::purge_done_procs()) + if self.nb_cache.is_empty() { + self.nb_initial_song_count = 0; + } + if crate::process_manager::proc_count() == 0 && self.nb_cache.is_empty() { + Ok(None) + } else { + Ok(Some(crate::process_manager::purge_done_procs())) + } } @@ -76,6 +82,47 @@ impl Downloader { Ok(self.count) } + pub fn download_playlist(&mut self, cfg: &ConfigWrapper, url: &String, pname: &String, format: &Format) -> anyhow::Result { + self.download_playlist_nb(cfg, url, pname, format)?; + let mut count = 0; + while let Some(c) = self.download_all_nb_poll(cfg)? { + count += c; + } + Ok(count) + } + + pub fn download_playlist_nb(&mut self, cfg: &ConfigWrapper, url: &String, pname: &String, format: &Format) -> anyhow::Result> { + log::warn!("This automatically assumes its a youtube link as it is currently the only supported playlist source"); + let mut cmd = tokio::process::Command::new(&cfg.cfg.ytdlp.path); + cmd.args([ + "--flat-playlist", + "--simulate", + "-O", "%(url)s|%(title)s", + url.as_str() + ]); + cmd + .stderr(Stdio::null()) + .stdout(Stdio::piped()); + + let ftr = cmd.output(); + + let mut ret = HashMap::new(); + + let out = futures::executor::block_on(ftr)?.stdout; + let out = String::from_utf8(out)?; + for line in out.lines() { + let mut split_text = line.split("|").collect::>(); + let url = split_text.swap_remove(0).to_string(); + let sname = split_text.join("|"); + let song = Song::from_url_str(url)?.set_type(SongType::Youtube).clone(); + self.nb_cache.push((pname.clone(), sname.clone(), song.clone(), format.clone())); + ret.insert(sname, song.clone()); + } + self.nb_initial_song_count += out.lines().count(); + self.download_all_nb_poll(cfg)?; + Ok(ret) + } + pub fn download_song(&mut self, cfg: &ConfigWrapper, name: &String, song: &Song, playlist: &String, format: &Format) -> anyhow::Result<()> { let dl_dir = format!("{}/{playlist}", cfg.cli.output); let dl_file = format!("{dl_dir}/{}.{}", name, &format); diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 99f4e13..07e922f 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -43,23 +43,23 @@ impl Manifest { pub fn get_format(&self) -> &Format { &self.format } - pub fn add_song(&mut self, playlist_name: String, name: SongName, song: Song) -> Option { + pub fn add_song(&mut self, playlist_name: &String, name: SongName, song: Song) -> Option { self.get_playlist_mut(playlist_name)?.add_song(name, song) } - pub fn get_song(&self, playlist_name: String, name: &String) -> Option<&Song> { + pub fn get_song(&self, playlist_name: &String, name: &String) -> Option<&Song> { self.get_playlist(playlist_name)?.get_song(name) } - pub fn get_song_mut(&mut self, playlist_name: String, name: &String) -> Option<&mut Song> { + pub fn get_song_mut(&mut self, playlist_name: &String, name: &String) -> Option<&mut Song> { self.get_playlist_mut(playlist_name)?.get_song_mut(name) } pub fn add_playlist(&mut self, playlist_name: String) { self.playlists.insert(playlist_name, Default::default()); } - pub fn get_playlist(&self, playlist_name: String) -> Option<&playlist::Playlist> { - self.playlists.get(&playlist_name) + pub fn get_playlist(&self, playlist_name: &String) -> Option<&playlist::Playlist> { + self.playlists.get(playlist_name) } - pub fn get_playlist_mut(&mut self, playlist_name: String) -> Option<&mut playlist::Playlist> { - self.playlists.get_mut(&playlist_name) + pub fn get_playlist_mut(&mut self, playlist_name: &String) -> Option<&mut playlist::Playlist> { + self.playlists.get_mut(playlist_name) } pub fn get_playlists(&self) -> &HashMap { &self.playlists diff --git a/src/process_manager.rs b/src/process_manager.rs index 9615d43..12f65fc 100644 --- a/src/process_manager.rs +++ b/src/process_manager.rs @@ -38,6 +38,9 @@ pub fn add_proc(mut cmd: Command, msg: String) -> anyhow::Result<()> { Ok(()) } +pub fn proc_count() -> usize { + PROCESSES.lock().unwrap().read().unwrap().len() +} pub fn is_proc_queue_full(max: usize) -> bool { let proc_cnt = PROCESSES.lock().unwrap().read().unwrap().len();