mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 01:23:02 +00:00
Compare commits
No commits in common. "50e7402c92a46ddaa8c2065532b701b0edebbb93" and "447c7e020d4377de9e173fcd37413bdd145f5101" have entirely different histories.
50e7402c92
...
447c7e020d
@ -13,12 +13,7 @@ parser = argparse.ArgumentParser(
|
|||||||
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')
|
||||||
parser.add_argument('-t', '--tag')
|
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()
|
args = parser.parse_args()
|
||||||
if args.instance:
|
|
||||||
instances = [args.instance]
|
|
||||||
|
|
||||||
|
|
||||||
def create_playlist_file(track_list):
|
def create_playlist_file(track_list):
|
||||||
@ -51,24 +46,10 @@ def filter_tracks(tracks):
|
|||||||
tracks_stor.append(i)
|
tracks_stor.append(i)
|
||||||
|
|
||||||
|
|
||||||
def search_tracks_on_instance(instance, tag='', query='', recursion=args.recursion):
|
def search_tracks_on_instance(instance, tag='', query=''):
|
||||||
tracks = 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,
|
'local': True, 'playable': True,
|
||||||
'ordering': 'random'}, timeout=10).json()
|
'ordering': 'random'}, timeout=10).json()
|
||||||
count = tracks['count']
|
|
||||||
print(f'found {count} tracks on {instance}')
|
|
||||||
if recursion == 1:
|
|
||||||
recursion_limit = 0
|
|
||||||
while tracks['next']:
|
|
||||||
try:
|
|
||||||
if recursion_limit >= args.depth:
|
|
||||||
break
|
|
||||||
new_tracks = requests.get(tracks['next']).json()
|
|
||||||
tracks['results'] += new_tracks['results']
|
|
||||||
tracks['next'] = new_tracks['next']
|
|
||||||
recursion_limit += 1
|
|
||||||
except Exception as E:
|
|
||||||
print(E)
|
|
||||||
tracks_replacer = []
|
tracks_replacer = []
|
||||||
for track in tracks['results']:
|
for track in tracks['results']:
|
||||||
track['listen_url'] = f'https://{instance}' + track['listen_url']
|
track['listen_url'] = f'https://{instance}' + track['listen_url']
|
||||||
|
Loading…
Reference in New Issue
Block a user