VideoHelp Forum


Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!


Try StreamFab Downloader and download streaming video from Youtube, Netflix, Amazon! Download free trial.


+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Member xplorr's Avatar
    Join Date
    Feb 2017
    Location
    Europe
    Search PM
    Since Youtube Music has no import/export/syncing functions (yet) to sync playlists with a local music collection, I decided to write some Python scripts myself to sync my WACUP/WinAmp m3u8 playlists to Youtube Music. I named my toolkit WinaYo and decided to share it as freeware. Enjoy!

    Introduction to WinaYo

    WinaYo is a freeware command line toolkit and user-interface to update/sync/delete and import/export Youtube Music playlists (YTM) with local playlists (m3u8) using Python and ytmusicapi. The target audience are people who have organized their music and playlist collection using a local media player like WinAmp, WACUP, ... and want to sync their collection to YTM. Currently YTM has no tool to sync local playlists. WinaYo fills this gap.
    WinaYo also allows to backup your YTM playlists to csv files, which you can edit in Excel or WinAmp, WACUP, ... and import back into YTM. Deleting all your playlists is also supported. WinaYo can easily be modified to sync playlists from other local music players/managers.

    Important remarks/limitations

    • WinaYo asumes that the filenames of your song collection are formatted as <Artist> - <Title>.mp3. If this is not the case, either you need to adjust WinaYo to fit another naming convention (see 4-WinAmp2GooglePlayList.bat) or you can easily reformat either your filenames or your tags to make them consistent using mp3tag.
    • WinaYo will not delete or create songs in YTM, only playlists are deleted/recreated/updated. To delete or upload songs you can use the YTM webclient.
    • Ytmusicapi has no reliable way of returning the YTM songids (recently) added, so every time you upload a batch of new songs to YTM, you should export all YTM songids to update the local database.
    • A maximum of 100000 songid's can be handled.
    • A maximum of 1000 playlists can be handled.
    • A maximum of 5000 songs per playlist can be handled (if playlists are >5000 songs, they will be automatically split into "<name> Part 1,2,3,...")
    • There is a limit on the number of Youtube apicalls Google allows (quota limit unknown)

    Version History

    Version 1.0 (14/08/2020) export YTM songsids and playlists functions
    Version 1.1 (16/08/2020) import/create playlists functions
    Version 1.2 (20/08/2020) delta updating functions
    Version 1.3 (23/08/2020) user-interface implemented

    Download and Installation

    • Download WinaYo.zip.
    • Unzip WinaYo.zip to a permanent directory (f.i. C:\WinaYo).

    License

    This software is distributed as freeware.



    Prerequisites

    • Install Python >=3.5 from https://www.python.org/downloads/ (future versions may include compiled .exe's so to avoid the need for installing python)
    • Install python ytmusicapi (by sigma67): pip install ytmusicapi (see https://github.com/sigma67/ytmusicapi)
    • Install python configparser: pip install configparser
    • Install other unknown python modules when receiving errors: pip install <module>
    • Add a valid YTM cookie in the file "headers_auth.json" to authenticate (replace cookie data between "")(see below)
    • Optional: Download and install "ML Exporter v1.0" for WinAmp to export all Smart Views (see http://winampplugins.co.uk/mlexporter.html) (builtin in WACUP)
    • Optional: Install rxrepl.exe from https://sites.google.com/site/regexreplace/ (already included in this project zip)
    • Optional: Install csvquery.exe (already included in this project zip)
    • Optional: "import" and "export" folders contain some example playlists for demo purposes (files can be deleted)

    Get a valid YTM Cookie using Chrome/Chromium/Edge to authenticate

    • open https://music.youtube.com in Chrome/Chromium/Edge
    • open dev tools (ctrl-shift-i)
    • do some action in main page (f.i. open playlists)
    • goto network tab
    • filter on "json" and select latest entry
    • look in "header" tab for string "cookie" and copy data
    • open "headers_auth.json" and copy cookie data to "cookie" and save
    • remark: this cookie will be valid as long as you don't logout from YTM

    Collect/Export WinAmp/WACUP SmartView Playlists (auto generated) to m3u8

    • Create a WinAmp/WACUP Smartview called "All" containing all your WinAmp/WACUP songs (query: artist ISNOTEMPTY AND title ISNOTEMPTY) (needed to compare against YTM later-on)
    • Open WinAmp/WACUP and click in lower left corner on "Library/Export/Smart Views/All Smart Views"
    • Select m3u8 format and folder "import"
    • Remark: Sometimes export fails, fix: restart WinAmp/WACUP and immediately do the export as fast as possible (also disable WinAmp/WACUP option: preferences/media library/local library/rescan folders at startup)

    Collect/Export WinAmp/WACUP Static Playlists (manually created) to m3u8

    • Select (static) "Playlists" foldertab and select all (static) playlists you want to upload to YTM and click "Save"
    • Select m3u8 format and folder "import"

    Scenario 1: Create and export WinAmp/WACUP playlists to YTM (initial upload)

    • First upload your WinAmp/WACUP songs collection to YTM using the YTM webclient (initial upload)(at the moment there is no other decent upload tool).
    • Collect/export your WinAmp/WACUP smartviews and static playlists into folder "import" (as described above).
    • Edit file "PlaylistsToDelete.txt" containing the names of the YTM playlists to delete (valid names can be found in file "export\Playlists.csv" after step 1)
    • Edit file "PlaylistsToCreate.txt" containing the names of the WinAmp/WACUP playlists to create in YTM (see folder import after step 4)
    • Perform the following steps:

    • Run 0-CorrectWAPlayListPaths.bat : locally remove unwanted WinAmp/WACUP playlists and correct songpaths (you have to review the bat file to your needs)
    • Run 1-ExportYTMusicLibrary.bat : export all uploaded YTM songid's in a playlist called "export\All.csv" and YTM playlistid's to "export\Playlists.csv" (run initially and when new songs are uploaded to YTM)
    • Run 2-ExportYTMusicPlayLists.bat : export all YTM playlists to a folder "export" (run as a backup and to check differences with WinAmp/WACUP later-on)
    • Run 3-DeleteYTMusicPlayLists.bat : delete all YTM playlists specified in file "PlaylistsToDelete.txt" (run only when you want to (re-)upload all playlists later-on)
    • Run 4-WinAmp2YTMusicPlayLists.bat : locally convert the WinAmp/WACUP playlist csv's to YTM playlist csv's with matching YTM songid's (after running 1-ExportYTMusicLibrary.bat)
    • Run 5-CreateYTMusicPlayLists.bat : create and upload all WinAmp/WACUP playlists to YTM playlists specified in file "PlaylistsToCreate.txt" (new YTM playlists are created!)

    Remark: everytime you upload a batch of new songs to YTM, you should run "1-ExportYTMusicLibrary.bat" to update the local songid database.

    Scenario 2: Sync WinAmp/WACUP playlists to YTM (append/remove)

    • Use this scenario to sync(append/remove) your playlists after you initially performed Scenario 1 (initial upload)(use this for relatively smaller delta's).
    • Collect/export your WinAmp/WACUP smartviews and static playlists into folder "import" (as described above).
    • Edit file "PlaylistsToUpdate.txt" containing the names of the YTM playlists to update (valid names can be found in file "export\Playlists.csv" after step 1)
    • Remark: current version of WinaYo does not allow to sync(append/remove) split playlists (>5000 songs, with <name> split into "<name> Part 1,2,3,...")(use DeleteList.py() and CreateList.py() instead)
    • Perform the following steps:

    • Run 0-CorrectWAPlayListPaths.bat : locally remove unwanted WinAmp/WACUP playlists and correct songpaths (you have to review the bat file to your needs)
    • Run 4-WinAmp2YTMusicPlayLists.bat : locally convert the WinAmp/WACUP playlist csv's to YTM playlist csv's with matching YTM songid's (after running 1-ExportYTMusicLibrary.bat)
    • Run 6-WASongsNotInYT.bat : report songs in WinAmp/WACUP not present in YTM and save result in "delta\WASongsNotInYT.csv" (optional)
    • Run 7-YTSongsNotInWA.bat : report songs in YTM not present in WinAmp/WACUP and save result in "delta\YTSongsNotInWA.csv" (optional)
    • Run 8-CopyWASongsNotInYT2Temp.bat : copy new songsfiles(mp3) present in WinAmp/WACUP but not in YTM to "temp" folder (upload to YTM using YTM webclient)(files may be removed after uploading)
    • Run 1-ExportYTMusicLibrary.bat : export all uploaded YTM songid's in a playlist called "export\All.csv" and YTM playlistid's to "export\Playlists.csv" (run only when new songs are uploaded to YTM)
    • Run 9-UpdateYTMusicPlayLists.bat : update/sync only YTM playlists different From WinAmp/WACUP playlists specified in "PlaylistsToUpdate.txt" (append/remove songs from YTM playlists)
    • Run 2-ExportYTMusicPlayLists.bat : export all YTM playlists to a folder "export" (run only to update local YTM playlists to check differences with WinAmp/WACUP later-on)

    Remark: everytime you upload a batch of new songs to YTM, you should run "1-ExportYTMusicLibrary.bat" to update the local songid database.

    Using the Userinterface

    Scenarios 1 and 2 are also available via the userinterface "WinaYo.exe". Actions are grouped in 4 groups:

    • Export Youtube Music Database
    • Prep/Convert WinAmp/WACUP Playlists
    • Report/Gather Song Differences
    • Create/Update/Delete Youtube Music Playlists

    The left column of actionbuttons start one of the above mentionned .bat files.
    The right column of actionbuttons allow to browse the folders, edit the preferences files or view the reports.
    Remark: everytime you upload a batch of new songs to YTM, you should click "Export Youtube Music Songids" to update the local songid database.

    Disclaimer

    This software and the accompanying files are supplied "as is", without any express or implied warranty. In no event shall the author be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages from the use of this software. By using this software you agree with these conditions.
    Last edited by xplorr; 7th Sep 2020 at 06:07.
    Quote Quote  
  2. Member
    Join Date
    Jan 2021
    Location
    Australia
    Search PM
    Signed up to say thanks for making this tool. I also sent you some coffee money via Paypal

    Since google got rid of Google Play Music, I have been looking for a way to get my playlists into Youtube Music. The automated transfer from google only moved over the songs that I added via stream, it ignored all local device songs in the playlists, which made up the majority of my playlists.

    I had to modify the batch files to suit my purposes. I will put some information here to potentially help others, especially those who want to transfer playlists from MusicBee to Youtube Music. If you want your playlists to include a combination of your own music and streamed music/videos, you have no choice but to upload your music first. Playlists in YTM can't include both streamed and local device songs, but can have streamed and uploaded songs.

    To summarise how this tool works (at a basic level). The tool will connect to YTM and export your uploaded music into a CSV file called All.csv. The export includes songid, which is a unique identifier assigned to each uploaded song. You then export your music from Winamp (or whatever) as an m3u8 file, which looks something like:

    Pop.m3u8:
    #EXTM3U
    #EXTINF:306,Keane - A Bad Dream
    \MP3\K\Keane - A Bad Dream.mp3
    #EXTINF:307,Coldplay - Clocks
    \MP3\C\Coldplay - Clocks.mp3

    The tool will then extract the artist and title from the file name in the path and create a .tmp file:

    Pop.tmp:
    artist,title,playlist
    "Keane","A Bad Dream","Pop"
    "Coldplay","Clocks","Pop"

    The tool then queries the tmp files against the all.csv file to create a csv file which includes the songid from YTM. The tool can then import this csv to YTM to create/update the playlists:

    Pop.csv:
    title,artist,playlist,songid
    A Bad Dream,Keane,Pop,Hy60PsoVkjY
    Clocks,Coldplay,Pop,Is0LTaQkuTo

    The two big issues I had with the tool:

    1) It assumes all my songs are named as <artist> - <title>.mp3. Even though I can export from MB as m3u8, my music library file names are not that consistently named and they are not all mp3. It's more important in MusicBee/YTM that the tags are correct, more so than the file name.
    2) To generate the CSV file, it does a joined query against the exported list (all.csv) and matching both artist and title. The issue is that my uploaded library has a lot of duplicates as it is organised by album. So I might have original album, plus greatest hits etc. So if I have a song like John Lennon - Imagine, it is in my library in like 5 different places, all with unique songids. If this is in my playlist, the csvquery matches every one as a different match and my playlist ends up with a lot of duplicates.

    To solve these and get it working with MusicBee, I scrapped the *.m3u8 files and created the tmp files manually with help from MusicBee. Go to your MB playlist, go to Edit Preferences>Tags(2)>Set the "send to clipboard tags" to : |<Title>|,|<Artist>|,|<Album>|,|TestPlaylist1|
    Save changes. On your playlist, select all songs (Ctrl-A), right click on a selected song and click Send to>Clipboard. Open notepad and paste the data in. Insert a new row at the top and set it to artist,title,playlist. Do a Find/Replace (ctrl-H) and replace | with ". Save the file with the playlist name and extension of .tmp. TestPlaylist1 needs to be changed each different playlist with the correct playlist name. Feel free to come up with a more elegant solution to this.

    I modified "4-WinAmp2YTMusicPlayLists.bat" to remove all m3u8 stuff. I also modified the query line to include comparing the album as well (previously just Artist and Title). So new line is: csvquery "%%f" export\All.csv -q "SELECT csv.title,csv.artist,csv.playlist,csv2.songid FROM csv JOIN csv2 ON csv.title=csv2.title AND csv.artist=csv2.artist AND csv.album=csv2.album" > "import\%%~nf.csv". This solves the second issue above by my playlist only matching a specific album version of the song to avoid duplicates.
    Quote Quote  
  3. Member xplorr's Avatar
    Join Date
    Feb 2017
    Location
    Europe
    Search PM
    @newage: thanks for using, modifying an explaining how WinaYo works. You have understood it very well. The weakness of WinaYo is indeed that your filenames have to be consistently structured as <artist> - <title>.mp3. I realize that many collections are not consistently named like that. So it's almost impossible to create a sync tool to fit all situations.
    I'm glad that you ware able to modify and understand the bat files, which I left editable for that purpose.
    I can also add to your interesting comments that users kan restructure their filenames using a freeware tool called mp3tag. This tool allows to batch rename your filenames according to the tag information (assuming that your tags are correct). Setting tags correctly is also possible with mp3tag or WinAmp or other tools.

    I can also add that I can now successfully sync my playlists to Youtube Music with WinaYo, although I realize that in the age of streaming music, less people will keep a local collection of their music. On the other hand the possibilities of streaming services like Youtube Music or Spotify to manage and edit playlists and tag information is very limited, also dynamic/smart playlistst based on queries are not available (afaik) like they are in WinAmp.
    Last edited by xplorr; 8th Jan 2021 at 07:02.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!