Giter Site home page Giter Site logo

vredditshare's Introduction

vredditshare

Reddit bot that reuploads Reddit hosted video. Currently running under /u/vredditshare.

Setup

Create a file named credentials.ini in the root directory with the following content

[general]
mode = development|production
operator = username to be pinged on crash/other stuff

[database]
type = sqlite|mysql
# Settings for mysql
host = 
username =
password = 
database =

[reddit]
client_id = Reddit client id
client_secret = Reddit client secret
username = Reddit username
password = Reddit password

[imgur]
imgur_id = Imgur api id
imgur_secret = Imgur api secret
imgur_cookie = Cookie generated from an Imgur upload

[gfycat]
gfycat_id = gftcat id
gfycat_secret = gfycat secret

[streamable]
email = streamable account email
password = password

[catbox]
hash = your catbox account hash

From there run python main.py from the root directory to start. vredditshare requires Python 3.6+.

You will also need FFmpeg, FFprobe, and gifski binaries on the path or in the same directory.

Commentary

Here's some notes on the more interesting parts of the bot.

Context detection

The bot goes through a couple of steps to determine what the user was asking for. First thing it checks is whether or not the user gave a link in the summon comment themselves. Then it looks through the comment chain to see if there was a gif in the parent comments (it will choose the one last referenced in the chain). Finally, it checks the post for a link.

Reversing gifs/mp4s

vredditshare uses two different reversing procedures which it chooses based on a few different circumstances. If it is reversing an mp4 (which is the most common gif type nowadays, go figure), it does the reversal process with FFmpeg. For gifs, it exports each frame with FFmpeg and then reassembles them with gifski. Although gifski produces great gifs, it's very slow and so this process is usually avoided. The bot chooses a reversal method by making an educated guess as to whether the source was originally a gif or an mp4.

Gif Host Library

v3 of vredditshare introduces the new Gif Host Library, a new implementation of the code used to describe gifs and hosting websites. It aims to share as much code as possible between the sites, reducing implementation efforts as well as surface area for bugs. Hosts define several properties such as how to parse their links, upload capabilities,and limits. Instead of hard coding where the bot should upload gifs for every host, it is now decided dynamically through the properties of a gif, limits of the hosting sites, and other priorities. It's fairly sturdy even though it's new and abstracts away many annoyances, differences, and difficulties managing the gif host sites.

vredditshare's People

Contributors

pmdevita avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vredditshare's Issues

Imgur bug

Decided to upload to <class 'core.hosts.imgur.ImgurHost'> <core.hosts.GifFile object at 0x7f4
26a430f28>
getting imgur album id... ropLwxf
uploading... wat
{'data': {'error': {'code': 1003,
                    'exception': {},
                    'message': '[ropLwxf]: File type invalid (1)',
                    'type': 'Exception_UploadError'},
          'method': 'POST',
          'request': '/upload'},
 'status': 415,
 'success': False}
Traceback (most recent call last):
  File "main.py", line 55, in <module>
    result = process_comment(reddit, reddit.comment(message.id), q)
  File "/home/pmdevita/bots/vredditshare/core/process.py", line 148, in process_comment
    reversed_gif_file.audio)
  File "/home/pmdevita/bots/vredditshare/core/hosts/imgur.py", line 358, in upload
    id = imgurupload(file, gif_type, nsfw=nsfw)
  File "/home/pmdevita/bots/vredditshare/core/hosts/imgur.py", line 164, in imgurupload
    print("received wait ticket:", upload['data']['ticket'])

Sometimes eats requests without doing anything

Happened last time after a "Unable to connect to Reddit, is the internet down?" but sometimes vredditshare just sits there not doing anything with requests. It'll still forward messages to the operator though and when it exits it takes a long time, like it's marking a lot of messages as read

RIP in peace?

Is this abandoned? u/vredditshare hasn't uploaded anything in a month.

Imgur bug

RedditVideo-hhuubjl1frj31
Decided to upload to <class 'core.hosts.imgur.ImgurHost'> <core.hosts.GifFile object at 0x7fb259341f28>
getting imgur album id... py1VLz8
uploading... received wait ticket: 438fd535
waiting for processing...I have no idea what's going on
<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>

Source Crediting/Linking

When the bot reuploads. the source should be linked or credited somehow, either in the title or something

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.