/reddit_music_scrape

Gets music and art from reddit, makes monthly album with album art, adds to itunes automatically

Primary LanguageRuby

r/listentothis monthly scraper

About

This is a ruby script which scrapes r/listentothis and collects the top songs, downloading them and adding them automatically to the User's iTunes. It is recommended that this script is run once a month, towards the end of the month. Personally, I have set a crontab which will run this script at 12:30 pm (lunch-time) on the 28th day of each month (the 28th is late enough so that I can get the bulk of that month's content without having to worry about specific months being longer or shorter). Twenty top tracks are taken from the subreddit, downloaded and added to iTunes. Album art is generated by taking the top picture from r/earthporn for that month and adding text to it (month, year). The image is added in the files' metadata so that it shows up in itunes.

Features

This script's executables:

  • Gather JSON data from reddit, specifically the top songs from the past month
  • Parse that JSON data such that I have an array of URLs
  • Creates a file based on the name of the month in the local directory
  • For each URL, the file is downloaded in ALAC format (best iTunes quality possible) and added to said folder
  • When the folder contains 20 songs, the top photo from r/earthporn is grabbed from the reddit API
  • Text (title, month, year) is added to the photo in a random color
  • For each song, metadata including album name and album art is added
  • The entire monthly folder is added to the "automatically add to itunes" folder

Setup

In order to run this script, you must have the following installations:

  • Current version of Ruby
  • Current version of Python (for some of the gems)
  • Install all of the gems listed at the top of the file
  • Some may require dependencies which can be installed using homebrew (info in comments/google it)
  • An internet connection
  • iTunes for which the default file location has not been changed

Technology

  • Ruby
  • JSON/Reddit API
  • Taglib Gem
  • Open-Uri Gem
  • Find Gem
  • Mechanize Gem
  • Rmagick Gem

note: more info on the gems can be found in comments at the top of the file. Gemfile to come.