-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstreamtape2curl.py
More file actions
executable file
·25 lines (22 loc) · 927 Bytes
/
Copy pathstreamtape2curl.py
File metadata and controls
executable file
·25 lines (22 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
import re
import requests
import sys
PREFIX='https:/'
def get_curl_command(url: str) -> str:
html = requests.get(url).content.decode()
token = re.match(r".*document.getElementById.*\('norobotlink'\).innerHTML =.*?token=(.*?)'.*?;", html, re.M|re.S).group(1)
infix=re.match(r'.*<div id="ideoooolink" style="display:none;">(.*?token=).*?<[/]div>', html, re.M|re.S).group(1)
final_URL=f'{PREFIX}{infix}{token}'
orig_title=re.match(r'.*<meta name="og:title" content="(.*?)">', html, re.M|re.S).group(1)
return f"curl -L -o '{orig_title}' '{final_URL}'"
if __name__ == '__main__':
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} STREAMTAPE_URL...", file=sys.stderr)
sys.exit(1)
for url in sys.argv[1:]:
try:
command = get_curl_command(url)
print(command)
except Exception as e:
print(e, file=sys.stderr)