From 92a52dd2b8b0847faa851e3c59bb289330d42cd3 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 25 Jul 2024 14:38:57 +0300 Subject: [PATCH] raise for status in search --- funkwlplay.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/funkwlplay.py b/funkwlplay.py index b00bff3..5332974 100755 --- a/funkwlplay.py +++ b/funkwlplay.py @@ -76,9 +76,12 @@ def filter_tracks(tracks): 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, - 'ordering': 'random'}, timeout=10).json() + 'ordering': 'random'}, timeout=10) + r.raise_for_status() + tracks = r.json() + count = tracks['count'] print(f'found {count} tracks on {instance}') if recursion == 1: