You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
972 B
40 lines
972 B
from datetime import datetime
|
|
import re
|
|
|
|
streaming_urls = ["^https://www.youtube.com", "^https://player.odycdn.com", "^https://youtu.be"]
|
|
pics = ["^jpg\\?*", "^jpeg\\?*", "^gif\\?*", "^png\\?*", "^tif\\?*", "^tiff\\?*"]
|
|
|
|
|
|
def timestampToDate(ts):
|
|
return datetime.fromtimestamp(int(ts)/1000000).strftime("%y-%m-%d %H:%M")
|
|
|
|
|
|
def checkPic(ext):
|
|
for p in pics:
|
|
if re.search(p, ext) is not None:
|
|
return True
|
|
return False
|
|
|
|
|
|
def checkStreamingVideo(link):
|
|
for pattern in streaming_urls:
|
|
if re.search(pattern, link) is not None:
|
|
return True
|
|
return False
|
|
|
|
|
|
def checkReddit(link):
|
|
return re.search("^https://www.reddit.com", link) is not None
|
|
|
|
|
|
def checkRedditComments(links):
|
|
for link in links:
|
|
if re.search("^https://www.reddit.com/[a-zA-Z1-9/]+/comments", link) is not None:
|
|
return link
|
|
return False
|
|
|
|
|
|
def writeLog(text):
|
|
with open("debug.log", "a") as f:
|
|
f.write(str(text))
|