diff options
author | Anthony Wang | 2023-05-31 18:26:26 -0500 |
---|---|---|
committer | Anthony Wang | 2023-05-31 18:26:26 -0500 |
commit | 35b0d4c3960c2ec7972cdff3a639925e497efb1d (patch) | |
tree | 505b048d452d8e012716a7450a2e5cc06c4d0d7f | |
parent | ebf8314278d6e45b95fc6b0d70f04d0fc86ce2d7 (diff) |
Display URL to video, show view counts for videos
-rwxr-xr-x | main.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 |