From 35b0d4c3960c2ec7972cdff3a639925e497efb1d Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Wed, 31 May 2023 18:26:26 -0500 Subject: Display URL to video, show view counts for videos --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index a3f8c52..1b3be4c 100755 --- a/main.py +++ b/main.py @@ -26,15 +26,17 @@ while True: body = gzip.decompress(urllib.request.urlopen(url + cur).read()).decode('utf-8') # Sometimes I forget what I'm even listening to # I WILL parse HTML with regex, you can't stop me - print('NOW PLAYING', cur, re.search('"true">(.*?)<', body).group(1)) + print('NOW PLAYING', url + cur, re.search('"true">(.*?)<', body).group(1)) # Get recommended stuff + lines = body.split('\n') rec = [ ( re.search('/video/(.*?)/', line).group(1), re.search('title="(.*?)"', line).group(1), - re.search('"name">(.*?)<', line).group(1) + re.search('"name">(.*?)<', line).group(1), + lines[i + 1].strip() ) - for line in body.split('\n') if 'recommend_more' in line + for i, line in enumerate(lines) if 'recommend_more' in line ] # Print it out the smart way! # Who needs loops smh -- cgit v1.2.3-70-g09d2