aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmain.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.py b/main.py
index 1b3be4c..224aa6c 100755
--- a/main.py
+++ b/main.py
@@ -28,13 +28,14 @@ while True:
# I WILL parse HTML with regex, you can't stop me
print('NOW PLAYING', url + cur, re.search('"true">(.*?)<', body).group(1))
# Get recommended stuff
+ # I figured out the regexes by playing around with curl --compressed and then grepping
lines = body.split('\n')
rec = [
(
- re.search('/video/(.*?)/', line).group(1),
- re.search('title="(.*?)"', line).group(1),
- re.search('"name">(.*?)<', line).group(1),
- lines[i + 1].strip()
+ re.search('/video/(.*?)/', line).group(1), # ID
+ re.search('title="(.*?)"', line).group(1), # Video name
+ re.search('"name">(.*?)<', line).group(1), # up主 name
+ lines[i + 1].strip() # View count
)
for i, line in enumerate(lines) if 'recommend_more' in line
]