From d792f1d648e397ba887309a0c8ec151b4426ef39 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Thu, 11 May 2017 22:06:27 -0500 Subject: [PATCH] Add the ability to add a proxy to youtube_dl --- README.md | 1 + cogs/utils/config.py | 6 ++++-- config.yml.sample | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2b6cd5..c141e95 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The only required file to modify would be the config.yml.sample file. The entrie - discord_bots_key: The key for the [bots.discord.pw site](https://bots.discord.pw/#g=1), if you don't have a key just leave it blank, it should fail and log the failure - carbon_key: The key used for the [carbonitex site](https://www.carbonitex.net/discord/bots) - twitch_key: The twitch token that is used for the API calls +- youtube_dl_proxy: A URL that can be used to proxy the calls youtube_dl goes through. Useful if your server is in a location that has many youtube videos blocked. - youtube_key: The key used for youtube API calls - osu_key: The key used for Osu API calls - db_*: This is the information for the rethinkdb database. diff --git a/cogs/utils/config.py b/cogs/utils/config.py index fd6bfb8..b66b5c4 100644 --- a/cogs/utils/config.py +++ b/cogs/utils/config.py @@ -10,7 +10,7 @@ global_config = {} try: with open("config.yml", "r") as f: global_config = yaml.safe_load(f) - global_config = {k: v if isinstance(v, str) and len(v) != 0 else None for k, v in global_config.items()} + global_config = {k: v for k, v in global_config.items() if v} except FileNotFoundError: print("You have no config file setup! Please use config.yml.sample to setup a valid config file") quit() @@ -56,7 +56,9 @@ lol_key = global_config.get('lol_key', '') # The invite link for the server made for the bot dev_server = global_config.get("dev_server", "") # The User-Agent that we'll use for most requests -user_agent = global_config.get('user_agent', "") +user_agent = global_config.get('user_agent', None) +# The URL to proxy youtube_dl's requests through +ytdl_proxy = global_config.get('youtube_dl_proxy', None) # The extensions to load extensions = ['cogs.interaction', 'cogs.misc', 'cogs.mod', 'cogs.admin', 'cogs.images', 'cogs.owner', 'cogs.stats', 'cogs.picarto', 'cogs.overwatch', 'cogs.links', diff --git a/config.yml.sample b/config.yml.sample index 623fc43..cb4fb8d 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -9,6 +9,7 @@ twitch_key: 'key' youtube_key: 'key' osu_key: 'key' dev_server: 'https://discord.gg/123456' +youtube_dl_proxy: 'https://myproxy.proxy:1234' user_agent: 'User-Agent/1.0.0 (Comment like link to site)'