-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (38 loc) · 1.36 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env python3
# encoding: utf-8
import sys
import datetime
from spotify import Spotify
from chirpScraper import Scrape
from playlist import Playlist
import json
import argparse
def worker_b(uri, playlist_name, most_recent):
'''Creates objects and does the real work
'''
scrape = Scrape(uri, most_recent)
tracks = scrape.get_tracks()
spotify = Spotify()
playlist = Playlist()
playlist.tracks = tracks
playlist.name = playlist_name
playlist.description = 'Not implemented yet'
playlist_id = spotify.create_playlist(playlist)
def main():
'''
Main method
'''
# initiate the parser
parser = argparse.ArgumentParser(description="Scrapes a DJ's playlist from the CHIRP radio \
(http://chirpradio.org/) and creates a Spotify playlist form it.")
parser.add_argument('-U', '--uri', required=True, help='set the dj profile url')
parser.add_argument('-N', '--name', required=True, help='set the name of the playlist')
parser.add_argument('-F', '--full', help='download the full dj playlist archive', action='store_false')
# read arguments from the command line
args = parser.parse_args()
uri = args.uri
playlist_name = args.name
most_recent = args.full
worker_b(uri, playlist_name, most_recent)
if __name__ == '__main__':
main()