diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2019-01-07 20:13:20 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2019-01-07 20:13:20 +0000 |
commit | caa23c670d168cc72f8cd332fc5792780c84e796 (patch) | |
tree | 42d97fc8803d86a0d66cf8ec692bb8022d753140 /test_ytapi.py | |
parent | 4a7c93c493af152884cb34ba34f6785b965e196b (diff) | |
parent | 3dc4ac293ad0959a14013eb0f5422db845bbfd42 (diff) | |
download | SmallYTChannelBot-caa23c670d168cc72f8cd332fc5792780c84e796.tar.gz SmallYTChannelBot-caa23c670d168cc72f8cd332fc5792780c84e796.zip |
updated database
Diffstat (limited to 'test_ytapi.py')
-rw-r--r-- | test_ytapi.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test_ytapi.py b/test_ytapi.py new file mode 100644 index 0000000..44f439f --- /dev/null +++ b/test_ytapi.py @@ -0,0 +1,69 @@ +import praw +import database +import login +import ytapi + +reddit = login.REDDIT + +subreddit = reddit.subreddit("jwnskanzkwktest") + +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/)" + +submission_stream = subreddit.stream.submissions(pause_after=-1) +while True: + + for submission in submission_stream: + if submission is not None: + + text = "Thank you for submitting..." + ytid = ytapi.get_videoId_from_url(submission.url) + 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) |