aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SmallYTChannelBotSubmissions.py14
-rw-r--r--SmallYTChannelDatabase.dbbin435200 -> 0 bytes
-rw-r--r--runprog.py12
-rw-r--r--test_ytapi.py50
-rw-r--r--ytapi.py19
5 files changed, 28 insertions, 67 deletions
diff --git a/SmallYTChannelBotSubmissions.py b/SmallYTChannelBotSubmissions.py
index db45e1e..ca447b7 100644
--- a/SmallYTChannelBotSubmissions.py
+++ b/SmallYTChannelBotSubmissions.py
@@ -242,12 +242,12 @@ def main():
else:
if score < 3:
text = """Thank you for submitting to /r/SmallYTChannel. Unfortunally, you submission has been removed since you do not have enough λ. You need
- 3λ to post. You currently have %iλ. For more information, read the [FAQ](https://www.reddit.com/user/SmallYTChannelBot/comments/a4u7qj/smallytchannelbot_faq/)""" % score
+ 3λ to post. You currently have %iλ. For more information, read the [FAQ.](https://www.reddit.com/user/SmallYTChannelBot/comments/a4u7qj/smallytchannelbot_faq/)""" % score
submission.mod.remove()
else:
text = """Thank you for submitting to /r/SmallYTChannel. You have spent 3λ to submit here, making your current balance %iλ.
/u/%s, please comment `!givelambda` to the most helpful advice you are given. You
- will be rewarded 1λ if you do so. For more information, read the [FAQ](https://www.reddit.com/user/SmallYTChannelBot/comments/a4u7qj/smallytchannelbot_faq/)""" % (score - 3, str(submission.author))
+ will be rewarded 1λ if you do so. For more information, read the [FAQ.](https://www.reddit.com/user/SmallYTChannelBot/comments/a4u7qj/smallytchannelbot_faq/)""" % (score - 3, str(submission.author))
db.change_lambda(str(submission.author), -3)
try:
@@ -258,7 +258,7 @@ def main():
text += """
\n\n\n##Video data:
-Field|Data
+**Field**|**Data**
:-|:-
Title|%s
Thumbnail|[Link](%s)
@@ -270,7 +270,7 @@ Description|%s
##Channel Data:
-Field|Data
+**Field**|**Data**
:-|:-
Name|%s
Thumbnail|[Link](%s)
@@ -310,9 +310,9 @@ Views|%s
continue
if __name__ == "__main__":
- #file = open("pid.txt", "w")
- #file.write(str(os.getpid()))
- #file.close()
+ file = open("pid.txt", "w")
+ file.write(str(os.getpid()))
+ file.close()
print("\n####################\n[%s] RESTARTED\n####################\n" % get_time())
main()
diff --git a/SmallYTChannelDatabase.db b/SmallYTChannelDatabase.db
deleted file mode 100644
index 353833f..0000000
--- a/SmallYTChannelDatabase.db
+++ /dev/null
Binary files differ
diff --git a/runprog.py b/runprog.py
index a564678..4568c59 100644
--- a/runprog.py
+++ b/runprog.py
@@ -11,13 +11,13 @@ while True:
sleep(60 * 60 * 2)
- #print("closing...")
- #file = open("pid.txt", "r")
- #pid = file.readlines()[0]
- #file.close()
+ print("closing...")
+ file = open("pid.txt", "r")
+ pid = file.readlines()[0]
+ file.close()
- #subprocess.run(["kill", pid])
+ subprocess.run(["kill", pid])
thread.terminate()
- #print("killed ", pid)
+ print("killed ", pid)
diff --git a/test_ytapi.py b/test_ytapi.py
index 44f439f..622fda9 100644
--- a/test_ytapi.py
+++ b/test_ytapi.py
@@ -5,7 +5,7 @@ import ytapi
reddit = login.REDDIT
-subreddit = reddit.subreddit("jwnskanzkwktest")
+subreddit = reddit.subreddit("SmallYTChannel")
tail = "\n\n\n ^/u/SmallYTChannelBot ^*made* ^*by* ^/u/jwnskanzkwk. ^*PM* ^*for* ^*bug* ^*reports.* ^*For* ^*more* ^*information,* ^*read* ^*the* ^[FAQ.](https://www.reddit.com/user/SmallYTChannelBot/comments/a4u7qj/smallytchannelbot_faq/)"
@@ -20,50 +20,4 @@ while True:
if "/" not in ytid:
ytdata = ytapi.get_video_data(ytid)
- text += """
-\n\n\n##Video data:
-
-Field|Data
-:-|:-
-Title|%s
-Thumbnail|[Link](%s)
-Views|%s
-Length|%s
-Likes/Dislikes|%s/%s
-Comments|%s
-Description|%s
-
-##Channel Data:
-
-Field|Data
-:-|:-
-Name|%s
-Thumbnail|[Link](%s)
-Subscribers|%s
-Videos|%s
-Views|%s
-
- """ % (
- ytdata["title"],
- ytdata["thumbnail"],
- ytdata["views"],
- ytdata["length"],
- ytdata["likes"],
- ytdata["dislikes"],
- ytdata["comments"],
- ytdata["description"],
- ytdata["channel"],
- ytdata["channelThumb"],
- ytdata["subscribers"],
- ytdata["videos"],
- ytdata["channelViews"]
- )
-
- curflair = submission.link_flair_text
- if str(curflair) != "None":
- submission.mod.flair(" %s | %s | :youtube: %s" % (curflair, ytdata["length"], ytdata["channel"]))
- else:
- submission.mod.flair("%s | :youtube: %s" % (ytdata["length"], ytdata["channel"]))
-
- reply = submission.reply(text + tail)
- reply.mod.distinguish(sticky = True)
+ print(ytdata["length"], submission.url)
diff --git a/ytapi.py b/ytapi.py
index b472b7e..267449b 100644
--- a/ytapi.py
+++ b/ytapi.py
@@ -33,17 +33,24 @@ get_videoId_from_url = js2py.eval_js(r"""function $(url){
}""")
def _yt_time_to_norm(time):
+ origtime = time
if time == "ERROR Video deleted?":
return time
- time = time.replace("M", ":")[2:].replace("S", "")
+ time = time[2:].replace("H", ":").replace("M", ":").replace("S", "")
+
+ out = ""
+ for i in time.split(":"):
+ if len(i) == 1:
+ out += "0" + i + ":"
+ elif len(i) == 0:
+ out += "00:"
+ else:
+ out += i + ":"
+
+ return out[:-1]
- s = time.split(":")
- if len(s) > 1:
- if len(s[1]) < 2:
- time = s[0] + ":" + s[1] + "0"
- return time
#this would be better as a class but I can't be bothered so dictionary it is
def get_video_data(videoId):