add depth arg

This commit is contained in:
localhost_frssoft 2024-07-24 17:51:53 +03:00
parent c1d53370b2
commit 50e7402c92

View File

@ -15,6 +15,7 @@ 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]
@ -60,7 +61,7 @@ def search_tracks_on_instance(instance, tag='', query='', recursion=args.recursi
recursion_limit = 0
while tracks['next']:
try:
if recursion_limit >= 5:
if recursion_limit >= args.depth:
break
new_tracks = requests.get(tracks['next']).json()
tracks['results'] += new_tracks['results']