Skip to content

Commit

Permalink
Switch to shuf/gshuf for bash script. Add future ideas to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Jones committed May 26, 2016
1 parent 3124dc8 commit da1f4d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ Archive.org has begun cataloging thousands of mixtapes from various collections
## caveats

I have included a bash script for those that don't want to register at archive.org. The caveat here is that this script uses a pretty sloppy `curl` and is not guaranteed to work for any forseeable future. To use the bash script just clone the repo and execute as you would any other script. It only requires mplayer if you're on linux. If you are on OS X you will need to `brew install coreutils`

## future work
* Command line options for things like continuous play of random tapes
* Create mixtape from individual songs pulled from other mixtapes by criteria (artist, year, genre)
* Better formatting
* Bundle for pip install
* Versions for python 2.x and 3.x that don't require hacky workarounds
8 changes: 4 additions & 4 deletions mixtape
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ else
fi

if [[ "$os" == "Darwin" ]]; then
if hash gsort 2>/dev/null; then
sortcommand="gsort"
if hash gshuf 2>/dev/null; then
shufcommand="gshuf"
else
echo "You need to install coreutils!"
exit 1
fi
elif [[ "$os" == "Linux" ]]; then
sortcommand="sort"
shufcommand="shuf"
fi

mixtape=`curl -s https://archive.org/advancedsearch.php\?q\=collection%3A%28hiphopmixtapes%29\&fl%5B%5D\=identifier\&sort%5B%5D\=\&sort%5B%5D\=\&sort%5B%5D\=\&rows\=100000\&page\=1\&output\=json\&callback\=callback\&save\=yes | grep identifier | cut -f2 -d ":" | cut -f2 -d "\"" | $sortcommand -R | head -n 1`
mixtape=`curl -s https://archive.org/advancedsearch.php\?q\=collection%3A%28hiphopmixtapes%29\&fl%5B%5D\=identifier\&sort%5B%5D\=\&sort%5B%5D\=\&sort%5B%5D\=\&rows\=100000\&page\=1\&output\=json\&callback\=callback\&save\=yes | grep identifier | cut -f2 -d ":" | cut -f2 -d "\"" | $shufcommand | head -n 1`

playlist="http://archive.org/download/${mixtape}/${mixtape}_vbr.m3u"

Expand Down
5 changes: 1 addition & 4 deletions mixtape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
'''Play a random mixtape from archive.org hiphopmixtapes collection using python and mplayer'''

import internetarchive
from random import randint
import os
Expand All @@ -24,7 +23,7 @@ def random_or_artist():
elif choice == "q":
exit()
else:
print("You didn't choose either. Please make a valid choice!")
print("Please make a valid choice!")
random_or_artist()

def get_artist():
Expand Down Expand Up @@ -74,8 +73,6 @@ def artist_mixtape(artist_search):
mixtape = mixtapes[int(choice)]
return mixtape



def play_tape(mixtape):
print("Now playing " + mixtape)
command = "mplayer -msgcolor -msglevel all=0:demux=5:statusline=5 -playlist http://archive.org/download/" + mixtape + "/" + mixtape + "_vbr.m3u 2>/dev/null"
Expand Down

0 comments on commit da1f4d5

Please sign in to comment.