mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-23 19:49:21 +02:00
Compare commits
No commits in common. "92a52dd2b8b0847faa851e3c59bb289330d42cd3" and "3f700b6b8fcd0a2fdac653fcc1ebcbfe72b88e59" have entirely different histories.
92a52dd2b8
...
3f700b6b8f
|
@ -10,25 +10,23 @@ with open('instances') as instances:
|
|||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='funkwlplay',
|
||||
prog='funkwhale playlist',
|
||||
description='Create playlist from query or just random playlist tracks from funkwhale instances')
|
||||
parser.add_argument('-s', '--search', help='This global search on funkwhale instances, it matches artists, albums, tracks, etc...')
|
||||
parser.add_argument('-t', '--tag', help='This tag search, use this as genre search')
|
||||
parser.add_argument('-i', '--instance', help='Specify instance, by default search on all instances in instances file')
|
||||
parser.add_argument('-r', '--recursion', type=int, default=0, help='Use recursion if instance contain more than 50 tracks')
|
||||
parser.add_argument('-d', '--depth', type=int, default=5, help='Depth of recursion, default is 5 pages, 250 tracks')
|
||||
parser.add_argument('-s', '--search')
|
||||
parser.add_argument('-t', '--tag')
|
||||
parser.add_argument('-i', '--instance')
|
||||
parser.add_argument('-r', '--recursion', type=int, default=0)
|
||||
parser.add_argument('-d', '--depth', type=int, default=5)
|
||||
args = parser.parse_args()
|
||||
if args.instance:
|
||||
instances = [args.instance]
|
||||
|
||||
|
||||
def create_playlist_file(track_list):
|
||||
filename = 'playlist.m3u8'
|
||||
with open(filename, 'w') as file:
|
||||
with open('playlist.m3u8', 'w') as file:
|
||||
file.write('#EXTM3U\n')
|
||||
for i in track_list:
|
||||
file.write('\n' + i)
|
||||
print(f'Playlist saved as {filename}')
|
||||
|
||||
|
||||
def filter_tracks(tracks):
|
||||
|
@ -76,12 +74,9 @@ def filter_tracks(tracks):
|
|||
|
||||
|
||||
def search_tracks_on_instance(instance, tag='', query='', recursion=args.recursion):
|
||||
r = requests.get(f'https://{instance}/api/v1/tracks', params={'tag': tag, 'q': query,
|
||||
tracks = requests.get(f'https://{instance}/api/v1/tracks', params={'tag': tag, 'q': query,
|
||||
'local': True, 'playable': True,
|
||||
'ordering': 'random'}, timeout=10)
|
||||
r.raise_for_status()
|
||||
tracks = r.json()
|
||||
|
||||
'ordering': 'random'}, timeout=10).json()
|
||||
count = tracks['count']
|
||||
print(f'found {count} tracks on {instance}')
|
||||
if recursion == 1:
|
||||
|
|
Loading…
Reference in New Issue