xspf2m3u

simple XSPF to M3U conversion
git clone https://git.ce9e.org/xspf2m3u.git

commit
0bbfcf656b5d71982d8807aac0de300d9cbd7b8f
parent
a94678c4b8edfbc0f0704f59ec7221a45eb48be1
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-08-23 06:59
better youtube error handling

Diffstat

M xspf2m3u.py 10 +++++++---

1 files changed, 7 insertions, 3 deletions


diff --git a/xspf2m3u.py b/xspf2m3u.py

@@ -80,12 +80,14 @@ def search_youtube(q):
   80    80 	try:
   81    81 		info = ydl.extract_info('ytsearch:' + ' '.join(q), download=False)
   82    82 	except youtube_dl.utils.DownloadError:
   83    -1 		return None
   -1    83 		return None, None
   -1    84 	if not info['entries']:
   -1    85 		return None, None
   84    86 	info = info['entries'][0]
   85    87 	try:
   86    88 		_format = next(ydl_selector({'formats': info['formats']}))
   87    89 	except StopIteration:
   88    -1 		return None
   -1    90 		return None, None
   89    91 	filename = '{}-{}.{}'.format(
   90    92 		info['title'].replace('/', '_'),
   91    93 		info['id'],
@@ -144,7 +146,9 @@ def main():
  144   146 
  145   147 			if location is None and args.youtube and youtube_dl:
  146   148 				url, filename = search_youtube([q for q in track.values() if q])
  147    -1 				if args.outdir:
   -1   149 				if url is None:
   -1   150 					location = None
   -1   151 				elif args.outdir:
  148   152 					location = os.path.join(args.outdir, filename)
  149   153 					pool.download(url, location)
  150   154 				else: