Skip to content

Commit 61ce7b7

Browse files
committed
Commandline argument clean-up
Updated commandline arguments, reflected changes in Readme, removed dependency on soup
1 parent 6b88287 commit 61ce7b7

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

KEX.Py

+10-7
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@ def main():
2323
# start date time
2424
parser.add_argument('--mdyh',
2525
dest='mdyh',
26-
metavar='mdyh',
26+
help='Example: --mdyh \"01/31/2017T18\"',
27+
metavar='\"mm/dd/yyyyThh\"',
2728
required=False)
2829

2930
# number of hours to get playlist for; default to 3 hours
3031
parser.add_argument('--hours',
3132
dest='hours',
32-
metavar='hours',
33+
metavar='num_of_hours',
34+
help='Number of hours of KEXP playlist to grab. Default = 3 hours',
3335
default=3,
3436
required=False)
3537

3638
parser.add_argument('--playlist',
3739
dest='playlist',
3840
metavar='playlist',
41+
help='Spotify playlist name',
3942
required=True) # <-- FIXME just generate a default
4043

4144
parser.add_argument('--always_create_new_playlist',
@@ -50,9 +53,9 @@ def main():
5053
# Use current datetime if one not provided in args
5154
# FIXME should specify pacific timezone on this. currently assumes local
5255
if args.mdyh is not None:
53-
start_datetime = datetime.strptime(args.mdyh, '%m/%d/%Y %H')
56+
start_datetime = datetime.strptime(args.mdyh, '%m/%d/%YT%H') # FIXME check start date is in the past otherwise no songs will be returned
5457
else:
55-
start_datetime = datetime.now() # FIXME this will be a bug because end_time will be in the future
58+
start_datetime = datetime.now() # FIXME this may be a bug because end_time will be in the future. Check what happens on KEXP API
5659

5760
num_of_hours = int(args.hours)
5861
if num_of_hours is not None and num_of_hours > 0: # FIXME confirm failure if args.hours is not an int
@@ -68,11 +71,11 @@ def main():
6871
tracks = radio.get_tracks(datetime.utcfromtimestamp(start_datetime.timestamp()),
6972
datetime.utcfromtimestamp(end_datetime.timestamp()))
7073

71-
# Check that we have tracks, KEXP cache can get stale sometimes
72-
# debug: http://cache.kexp.org/cache/info
74+
# Check that we have tracks
75+
# debug: KEXP cache can get stale somtimes, http://cache.kexp.org/cache/info
7376
if len(tracks) == 0:
7477
print('No tracks found for: ' + start_datetime.strftime('%a %b %d, %Y %H:%M'))
75-
print('Perhaps the KEXP cache is stale? http://cache.kexp.org/cache/info') # FIXME lookup cache stats and offer evaluation
78+
print('Perhaps the KEXP cache is stale? See http://cache.kexp.org/cache/info') # FIXME lookup cache stats and offer evaluation
7679
sys.exit(0)
7780

7881
# Lookup tracks in Spotify

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Obtain a Spotify client ID and secret from https://developer.spotify.com/my-appl
1414

1515
## Running KEX.Py
1616

17-
The KEXP program Shake the Shack airs every Friday between six and nine. To build a playlist entitled "Shake the Shack" from the December 30th KEXP playlist, run the following:
17+
The KEXP program Shake the Shack airs every Friday between six and nine PM. To build a playlist entitled "Shake the Shack" from the December 30th KEXP playlist, run the following:
1818

1919
```
2020
$ source spotipy-env.sh
21-
$ ./KEX.Py --username <your-username> --playlist "Shake the Shack" --mdy 12/30/2016 --hour 18-21
21+
$ ./KEX.Py --username <your-username> --playlist "Shake the Shack" --mdyh "12/30/2016T18" --hours 3
2222
```
2323

2424

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
BeautifulSoup4
21
Spotipy

0 commit comments

Comments
 (0)