Vidgen

License

MIT License

Copyright (c) 2020 Scoder12

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Reference

vidgen.console

Command line interface.

vidgen.reddit

Reddit downloader client.

vidgen.reddit.post_to_dict(post, include_children=False, limit=None)

Processes the top level comments of a reddit post into a json object.

Gets all of the comments of the post,

Parameters
  • post (Submission) – The reddit post to get comments from

  • include_children (bool) – Whether to include non top-level comments

  • limit (Optional[int]) – The maximum amount of comments to return

Return type

dict

Returns

A dictionary with the post id, title, and a list of processed comment dictionaries with author, votes, ts, and body fields.

vidgen.reddit.process_text(text)

Processes text into human readable format.

Escapes all html entities and strips zero-width spaces.

Parameters

text (str) – The text to be processed

Return type

str

Returns

The processed text.

Vidgen is a python video generator.

Installation

To install vidgen, run this command:

$ pip install vidgen

Usage

To download a reddit post, use the redditdl commmand.

To run this command, you need to register a reddit API app first. You can do this at the Reddit Apps Page. Once you register an app, you need the Client ID, Client Secret, and a user agent like

<platform>:<app ID>:<version string> (by u/<Reddit username>)

You can pass these variables on the commandline or in environment variables. For more information about which environment variables to set, run

$ vidgen redditdl --help

You can download a post using its URL or its ID (which can be found in the url) and an output filename.

$ vidgen redditdl https://www.reddit.com/r/programming/comments/dhwtvt/python_38_released/ python.json

Or you can use a post ID (this has the same effect as the command above):

$ vidgen redditdl dhwtvt python.json

Note

These examples don’t include the client ID or client secret command line options.

You have to add these on after the command unless you’re using environment variables.

These client ID can be passed with the -cid or –client-id option, the client secret in the -csec or –client-secret option, and the user-agent in the -ua or –user-agent option.

For example:

-cid xxxxxxxx -csec xxxxxxxxx -ua "python:someproject:v0.0.1 (Made with love by /u/Scoder12)"