aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-12-25 00:13:52 -0800
committerJames Taylor <user234683@users.noreply.github.com>2018-12-25 00:13:52 -0800
commit5ffe9a4030db19a22b329da8d0c5f6bfed5cc6d3 (patch)
treed875861f8e1bb2bb76f0ea9fda05593689aa295d /youtube
parent8f5edfe6f994e765a0207d7bbb5897de06a2ceb4 (diff)
downloadyt-local-5ffe9a4030db19a22b329da8d0c5f6bfed5cc6d3.tar.lz
yt-local-5ffe9a4030db19a22b329da8d0c5f6bfed5cc6d3.tar.xz
yt-local-5ffe9a4030db19a22b329da8d0c5f6bfed5cc6d3.zip
Function to produce LWPCookieJar from lwp string
Diffstat (limited to 'youtube')
-rw-r--r--youtube/accounts.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/youtube/accounts.py b/youtube/accounts.py
index a8362b9..53b3d49 100644
--- a/youtube/accounts.py
+++ b/youtube/accounts.py
@@ -6,7 +6,7 @@ from youtube import common
import re
import settings
import http.cookiejar
-
+import io
try:
with open(os.path.join(settings.data_dir, 'accounts.txt'), 'r', encoding='utf-8') as f:
@@ -28,6 +28,12 @@ def add_account(username, password, save):
"cookies":cookie_jar.as_lwp_str(ignore_discard=False, ignore_expires=False),
}
+def cookie_jar_from_lwp_str(lwp_str):
+ cookie_jar = http.cookiejar.LWPCookieJar()
+ # HACK: cookiejar module insists on using filenames and reading files for you,
+ # so present a StringIO to this internal method which takes a filelike object
+ cookie_jar._really_load(self, io.StringIO(lwp_str), "", False, False)
+ return cookie_jar
# ---------------------------------
# Code ported from youtube-dl