Skip to content

Instantly share code, notes, and snippets.

@jegfish
jegfish / example_db.py
Last active September 5, 2024 09:01
Example code for connecting to and using a postgres database using discord.py and asyncpg.
# asyncpg docs: https://magicstack.github.io/asyncpg/current/
# This uses discord.py rewrite branch and .format(). If you are using the async branch of discord.py, it shouldn't matter much
# as only 'await ctx.send()' is something you should need to change. If you are using python 3.6+, you can use f strings as opposed to
# .format() for increased efficiency.
import discord
from discord.ext import commands
import asyncio
import asyncpg
# https://github.com/ytdl-org/youtube-dl/blob/7947a1f7dbc6ba47a6f22ab67fd330e57c0ef87c/youtube_dl/YoutubeDL.py#L1811
# in process_info method of the YoutubeDL class in youtube_dl/YoutubeDL.py
# original as of writing this (latest commit fca6dba8b80286ae6d3ca0a60c4799c220a52650)
# youtube-dl version 2020.07.28
if subtitles_are_requested and info_dict.get('requested_subtitles'):
# subtitles download errors are already managed as troubles in relevant IE
# that way it will silently go on when used with unsupporting IE
subtitles = info_dict['requested_subtitles']
ie = self.get_info_extractor(info_dict['extractor_key'])
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 19370f62b..8dc4547c4 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -1813,6 +1813,7 @@ class YoutubeDL(object):
# that way it will silently go on when used with unsupporting IE
subtitles = info_dict['requested_subtitles']
ie = self.get_info_extractor(info_dict['extractor_key'])
+ failed_sub_langs = []
for sub_lang, sub_info in subtitles.items():
;(load "~/.emacs.d/jgf.el")
(load-theme 'modus-vivendi)
;; TODO: Make only explicit copy modify the system clipboard. Maybe
;; can do by binding copy key to a function that does that operation,
;; and setting the config option to not having the kill-ring synced to
;; system clipboard.
;; straight.el