mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-23 20:59:20 +02:00
Compare commits
3 Commits
3f700b6b8f
...
92a52dd2b8
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | 92a52dd2b8 | ||
localhost_frssoft | e3d523758d | ||
localhost_frssoft | bf5f4c9811 |
|
@ -10,23 +10,25 @@ with open('instances') as instances:
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='funkwhale playlist',
|
prog='funkwlplay',
|
||||||
description='Create playlist from query or just random playlist tracks from funkwhale instances')
|
description='Create playlist from query or just random playlist tracks from funkwhale instances')
|
||||||
parser.add_argument('-s', '--search')
|
parser.add_argument('-s', '--search', help='This global search on funkwhale instances, it matches artists, albums, tracks, etc...')
|
||||||
parser.add_argument('-t', '--tag')
|
parser.add_argument('-t', '--tag', help='This tag search, use this as genre search')
|
||||||
parser.add_argument('-i', '--instance')
|
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)
|
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)
|
parser.add_argument('-d', '--depth', type=int, default=5, help='Depth of recursion, default is 5 pages, 250 tracks')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.instance:
|
if args.instance:
|
||||||
instances = [args.instance]
|
instances = [args.instance]
|
||||||
|
|
||||||
|
|
||||||
def create_playlist_file(track_list):
|
def create_playlist_file(track_list):
|
||||||
with open('playlist.m3u8', 'w') as file:
|
filename = 'playlist.m3u8'
|
||||||
|
with open(filename, 'w') as file:
|
||||||
file.write('#EXTM3U\n')
|
file.write('#EXTM3U\n')
|
||||||
for i in track_list:
|
for i in track_list:
|
||||||
file.write('\n' + i)
|
file.write('\n' + i)
|
||||||
|
print(f'Playlist saved as {filename}')
|
||||||
|
|
||||||
|
|
||||||
def filter_tracks(tracks):
|
def filter_tracks(tracks):
|
||||||
|
@ -74,9 +76,12 @@ def filter_tracks(tracks):
|
||||||
|
|
||||||
|
|
||||||
def search_tracks_on_instance(instance, tag='', query='', recursion=args.recursion):
|
def search_tracks_on_instance(instance, tag='', query='', recursion=args.recursion):
|
||||||
tracks = requests.get(f'https://{instance}/api/v1/tracks', params={'tag': tag, 'q': query,
|
r = requests.get(f'https://{instance}/api/v1/tracks', params={'tag': tag, 'q': query,
|
||||||
'local': True, 'playable': True,
|
'local': True, 'playable': True,
|
||||||
'ordering': 'random'}, timeout=10).json()
|
'ordering': 'random'}, timeout=10)
|
||||||
|
r.raise_for_status()
|
||||||
|
tracks = r.json()
|
||||||
|
|
||||||
count = tracks['count']
|
count = tracks['count']
|
||||||
print(f'found {count} tracks on {instance}')
|
print(f'found {count} tracks on {instance}')
|
||||||
if recursion == 1:
|
if recursion == 1:
|
||||||
|
|
Loading…
Reference in New Issue