Reddit Liked List Builder
As a frequent Reddit user I find a lot of good new music browsing the electronic music subreddit but never had a good way to keep track of it. Wanting to relisten to a song I had previously liked I needed to browse through my liked history. However after a week or two any link I upvoted would be buried several pages deep, proving to be kind of a hassle.
The Reddit Liked Link Builder solves the problem of needing to manually search. This script will parse a users 'liked' history for a given subreddit and output a list of HTML links to a file. In its current state the Reddit link must have "media": data associated with it. This was done to prevent 'self' posts or regular article from appearing in the list.
Download the redditlikedlist.py and rll.cfg to a directory of your choice.
Populate the following fields in the rll.cfg file:
outputfile = The destination of the output file. Example: /home/John/musiclist.HTML
subreddit = The subreddit you want to parse from. Example: electronicmusic
beforelinkname = (leave blank, the script will populate)
username = Your Reddit username, must have a valid Reddit account to use this script.
password = Your Reddit password, must have a valid Reddit account to use this script.
useragent = Reddit requires a unique user agent for all calls to its API, it is recommended
you incorporate your username in the agent. Example: BobaFett37's Liked List Parse
format = (embeded|standard) The standard format will create a list of HTML href links.
The embeded format will create youtube and soundcloud embeded html in collapsible divs.
Prereqs for using embeded:
2) jQuery script/html
3) The css file and images for the collapsible/expandible div's.
Run the python script passing the configuration file location as a parameter:
$> python redditlikedlist.py rll.cfg
The first time the script is run it will start with your most recent liked links and work backwards into the past. Reddit will allow you to parse your most recent 1000 links. After the first run the script stores the most recent link in the 'beforelinkname' in the configuration file. Subsequent executions the script will start parsing from this link and work forward to present time.
The HTML file output will contain the last processed date stamp as well as a list of HTML links to media content. The src attributes have been labeled data-src and will be toggled on the expansion of the div to help speed up performance of the page load. Example:
Standard Output Sample
Last updated at: 2013-09-20 07:00:07<br/><br/> <a href='http://www.youtube.com/watch?v=XXXXXXXXXXX'>Music Video 1</a><br/> <a href='http://www.youtube.com/watch?v=XXXXXXXXXXX'>Music Video 2</a><br/> <a href='http://www.youtube.com/watch?v=XXXXXXXXXXX'>Music Video 3</a><br/> <a href='http://www.youtube.com/watch?v=XXXXXXXXXXX'>Music Video 4</a><br/> <a href='http://www.youtube.com/watch?v=XXXXXXXXXXX'>Music Video 5</a><br/>
Embeded Output Sample
<div class='togglevid'><img class="plus-img" src="/images/trans.png">Song 1 - Artist1</div> <div class='video'><iframe width='420' height='315' data-src='//www.youtube.com/embed/XXXXXXXXXX' frameborder='0' allowfullscreen></iframe></div> <div class='togglevid'><img class="plus-img" src="/images/trans.png">Song 2 - Artist 2</div> <div class='video'><iframe width="100%" height="166" scrolling="no" frameborder="no" data-src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%XXXXXXXXXX&show_artwork=true"></iframe></div>
- Validate Youtube links are still valid (i.e. not pulled by record labels or deleted by YouTube poster)
- Incorporate more than 1 subreddit to parse in config file.
- Add list sorting