-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from relaytheurgency/dev
Dev
- Loading branch information
Showing
3 changed files
with
28 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#!/usr/bin/python | ||
'''Play a random mixtape from archive.org hiphopmixtapes collection using python and mplayer''' | ||
#!/usr/bin/env python | ||
__author__ = "Brandon Jones" | ||
__copyright__ = "Copyright 2016, Brandon Jones" | ||
__license__ = "MIT License" | ||
__version__ = "1.0.0" | ||
__email__ = "[email protected]" | ||
|
||
'''Play a random mixtape from archive.org hiphopmixtapes collection using python and mplayer''' | ||
import internetarchive | ||
from random import randint | ||
import os | ||
|
@@ -10,6 +15,7 @@ | |
real_raw_input = vars(__builtins__).get('raw_input',input) | ||
|
||
def random_or_artist(): | ||
'''Have the user choose whether to search for a specific artist or play a random tape''' | ||
|
||
choice = real_raw_input("\ | ||
Would you like to: \n\ | ||
|
@@ -24,7 +30,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(): | ||
|
@@ -34,13 +40,14 @@ def get_artist(): | |
return artist_name | ||
|
||
def search_artist(artist_name): | ||
'''Search archive.org for tapes from an artist''' | ||
'''Search archive.org for tapes from an artist and return those tapes''' | ||
|
||
artist_tapes = internetarchive.search_items('collection:hiphopmixtapes AND title:' + artist_name) | ||
return artist_tapes | ||
|
||
def random_mixtape(): | ||
|
||
'''Return a random mixtape item''' | ||
|
||
mixtapes=[] | ||
|
||
for i in internetarchive.search_items('collection:hiphopmixtapes'): | ||
|
@@ -51,7 +58,8 @@ def random_mixtape(): | |
return mixtape | ||
|
||
def artist_mixtape(artist_search): | ||
|
||
'''Returns an artist specific mixtape the user chooses from''' | ||
|
||
mixtapes = [] | ||
for i in artist_search: | ||
mixtapes.append(i['identifier']) | ||
|
@@ -74,13 +82,14 @@ def artist_mixtape(artist_search): | |
mixtape = mixtapes[int(choice)] | ||
return mixtape | ||
|
||
|
||
|
||
def play_tape(mixtape): | ||
'''Calls mplayer to play a 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" | ||
os.system(command) | ||
print("\n") | ||
|
||
random_or_artist() | ||
|
||
random_or_artist() |