Skip to content

A spotify 'year wrapped' like for Google Play Music

Notifications You must be signed in to change notification settings

cinfulsinamon/ytmusic_wrapped

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Music Year Wrapper

This tool was updated in December 2020 by nirajsanghvi (give him a big thanks!) with the following modifications:

  • Optional -m parameter (best used in combination with -d) to show more details: total minutes played for top artists, and total number of plays and artist names for top songs
  • Optional -y/--year parameter to run the process for a specific year, report files are now suffixed with the year so you can easily generate and compare across years
  • Generate a new database for each run (my db was erroneously stacking all the data when running different years back-to-back)
  • Remove the " - Topic" noise from the artist names (for some reason all my artists were getting suffixed with this)
  • Formatting fixes and connection cleanup

Original description below:

A spotify year wrap like for YouTube Music

Note : This project is not endorsed by Google

example of a report

To use YouTube Music Year Wrapper


You will need to install Python. I used 3.8.0 32bit, so use that version if you want to be super safe. Be sure to select the "Add python to PATH" option in the installer.
Once python is installed, open up a console and run `pip install requests` to get the required module for this script.
Download this repo using git or by downloading the master.zip in browser.
Extract the zip file somewhere you can point a terminal to it.
Then download a history file from Google My Activity containing your YouTube Watch History.

NOTE: You must either switch your account language to English so the script can properly match strings in your history file, or edit the script to match your language. Specifically, you must change the strings and indexes in the should_not_ignore function as well as the indexes in the parse_json function.


To download a history file:

  1. Go here.
  2. Click Deselect All above the first checkbox.
  3. Scroll all the way down to YouTube, and only check that box.
  4. Click the button that says Multiple Formats.
  5. Next to History, select the JSON option from the dropdown box and Click OK.
  6. Click on the All YouTube data included button.
  7. Click Deselect All, and then only check History. Click OK.
  8. Scroll down and hit next step to finish your takeout.

You will need to extract the watch-history.json file from within the archive it generates. Place it in the same folder as the script to make things easier.

You can now launch the script with the following options :
python main.py [path/to/your/json/history_file]
-v to enable a full detailed log in log.dat
-d [YouTube API key] to enable duration calculation

NOTE: Running without the duration calculation will give you less accurate numbers for the total plays.

This is because your history file may contain entries which do not have a title or channel field, and the only way to fetch these is using the YouTube API with an API key. It will grab as many as it can and try to fill fields from other entries with the same URL, but you must use the -d option for the most accurate report which will only leave out removed videos that can't be found in the API.

Your report will be available in report.html and report.dat. Note that it usually takes less than 1 minute to complete a report. However -d option can increase this. An HTML file with a report formatted like the image above will be generated in the same folder as the script. If you want the font to look correct, you'll have to download and install the Roboto and Product Sans fonts.

About

A spotify 'year wrapped' like for Google Play Music

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%