1
1
import argparse
2
+
2
3
import samplify .platform as platform
3
4
from samplify .sample_finder import Samplify
4
5
from samplify .tools .options import Options
5
6
"""
6
7
CLI Frontend to Samplify
7
8
"""
8
9
10
+
9
11
def main ():
10
12
options = Options ()
11
13
parser = argparse .ArgumentParser ()
12
14
13
- # input platform, default = platform.SPOTIFY
15
+ ### input platform, default = platform.SPOTIFY
14
16
i_platform_group = parser .add_mutually_exclusive_group (required = False )
15
17
i_platform_group .add_argument (
16
- ' --input-spotify' ,
18
+ " --input-spotify" ,
17
19
action = "store_const" ,
18
20
const = platform .SPOTIFY ,
19
- dest = 'i_platform' )
21
+ dest = "i_platform" ,
22
+ )
20
23
21
- # output platform, default = platform.SPOTIFY
24
+ ### output platform, default = platform.SPOTIFY
22
25
o_platform_group = parser .add_mutually_exclusive_group (required = False )
23
26
o_platform_group .add_argument (
24
- ' --output-spotify' ,
27
+ " --output-spotify" ,
25
28
action = "store_const" ,
26
29
const = platform .SPOTIFY ,
27
- dest = 'o_platform' )
30
+ dest = "o_platform" ,
31
+ )
28
32
29
33
o_platform_group .add_argument (
30
- ' --output-youtube' ,
34
+ " --output-youtube" ,
31
35
action = "store_const" ,
32
36
const = platform .YOUTUBE ,
33
- dest = 'o_platform' )
37
+ dest = "o_platform" ,
38
+ )
34
39
35
40
o_platform_group .add_argument (
36
- ' --output-stdout' ,
37
- action = ' store_const' ,
41
+ " --output-stdout" ,
42
+ action = " store_const" ,
38
43
const = platform .STDOUT ,
39
- dest = 'o_platform' )
44
+ dest = "o_platform" ,
45
+ )
40
46
47
+ ### Link or Search
41
48
reference_group = parser .add_mutually_exclusive_group (required = True )
42
49
reference_group .add_argument (
43
- '-l' ,
44
- '--link' ,
45
- help = 'Click "Share" > "Copy Link"' )
50
+ "-l" , "--link" , help = 'Click "Share" > "Copy Link"'
51
+ )
46
52
47
53
reference_group .add_argument (
48
- '-s' ,
49
- '--search' ,
50
- help = 'Search as you would in the app' )
54
+ "-s" , "--search" , help = "Search as you would in the app"
55
+ )
51
56
57
+ ## (OR ALBUM PLAYLIST SONG CURRENT_SONG)
52
58
content_group = parser .add_mutually_exclusive_group (required = True )
53
59
content_group .add_argument (
54
- ' --album' ,
60
+ " --album" ,
55
61
action = "store_const" ,
56
62
const = options .ALBUM ,
57
- dest = 'content_type' )
63
+ dest = "content_type" ,
64
+ )
58
65
59
66
content_group .add_argument (
60
- ' --playlist' ,
67
+ " --playlist" ,
61
68
action = "store_const" ,
62
69
const = options .PLAYLIST ,
63
- dest = 'content_type' )
70
+ dest = "content_type" ,
71
+ )
64
72
65
73
content_group .add_argument (
66
- ' --song' ,
74
+ " --song" ,
67
75
action = "store_const" ,
68
76
const = options .SONG ,
69
- dest = 'content_type' )
77
+ dest = "content_type" ,
78
+ )
70
79
71
80
# FIXME: current song can't work with '--search'
72
81
content_group .add_argument (
73
- ' --current-song' ,
82
+ " --current-song" ,
74
83
action = "store_const" ,
75
84
const = options .CURRENT_SONG ,
76
- dest = 'content_type' )
85
+ dest = "content_type" ,
86
+ )
77
87
78
88
parser .add_argument ("--direction" )
79
89
parser .add_argument ("--output-name" )
80
90
parser .add_argument ("--output-type" )
81
91
parser .add_argument ("--username" )
82
92
93
+ ### DEBUG
83
94
debug_group = parser .add_mutually_exclusive_group (required = False )
84
95
debug_group .add_argument (
85
- '-v' ,
86
- help = ' Include function detail' ,
96
+ "-v" ,
97
+ help = " Include function detail" ,
87
98
action = "store_const" ,
88
99
const = 1 ,
89
- dest = 'verbosity' )
100
+ dest = "verbosity" ,
101
+ )
90
102
91
103
debug_group .add_argument (
92
- ' -vv' ,
93
- help = ' Multiline, include limited data' ,
104
+ " -vv" ,
105
+ help = " Multiline, include limited data" ,
94
106
action = "store_const" ,
95
107
const = 2 ,
96
- dest = 'verbosity' )
108
+ dest = "verbosity" ,
109
+ )
97
110
98
111
debug_group .add_argument (
99
- ' -vvv' ,
100
- help = ' Multiline, include full data' ,
112
+ " -vvv" ,
113
+ help = " Multiline, include full data" ,
101
114
action = "store_const" ,
102
115
const = 3 ,
103
- dest = 'verbosity' )
116
+ dest = "verbosity" ,
117
+ )
104
118
105
119
args = parser .parse_args ()
106
120
107
121
samplify = Samplify (
108
122
verbosity = args .verbosity or 0 ,
109
123
input_platform = args .i_platform or platform .SPOTIFY ,
110
- output_platform = args .o_platform or platform .SPOTIFY );
124
+ output_platform = args .o_platform or platform .SPOTIFY ,
125
+ )
111
126
112
127
result = None
113
128
if args .search :
@@ -116,38 +131,44 @@ def main():
116
131
direction = args .direction ,
117
132
content_type = args .content_type ,
118
133
output_name = args .output_name ,
119
- output_type = args .output_type )
134
+ output_type = args .output_type ,
135
+ )
120
136
121
137
elif options .type_is_playlist (args .content_type ):
122
138
result = samplify .playlist (
123
139
reference = args .link ,
124
140
direction = args .direction ,
125
141
output_name = args .output_name ,
126
142
output_type = args .output_type ,
127
- username = args .username )
143
+ username = args .username ,
144
+ )
128
145
129
- elif options .type_is_album (args .content_type ):
146
+ elif options .type_is_album (args .content_type ):
130
147
result = samplify .album (
131
148
reference = args .link ,
132
149
direction = args .direction ,
133
150
output_name = args .output_name ,
134
- output_type = args .output_type )
151
+ output_type = args .output_type ,
152
+ )
135
153
136
154
elif options .type_is_song (args .content_type ):
137
155
result = samplify .song (
138
156
reference = args .link ,
139
157
direction = args .direction ,
140
158
output_name = args .output_name ,
141
159
output_type = args .output_type ,
142
- username = args .username )
160
+ username = args .username ,
161
+ )
143
162
144
163
elif options .type_is_current_song (args .content_type ):
145
164
result = samplify .current_song (
146
165
reference = args .link ,
147
166
direction = args .direction ,
148
167
output_name = args .output_name ,
149
168
output_type = args .output_type ,
150
- username = args .username )
169
+ username = args .username ,
170
+ )
171
+
151
172
152
- if __name__ == ' __main__' :
173
+ if __name__ == " __main__" :
153
174
main ()
0 commit comments