mirror of
https://github.com/KevinMidboe/bulk-downloader-for-reddit.git
synced 2025-10-29 17:40:15 +00:00
@@ -169,7 +169,9 @@ Python have real issues about naming their program
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
### [11/07/2018]()
|
### [11/07/2018]()
|
||||||
- Improve UX and UI
|
- Improvements on UX and UI
|
||||||
|
- Added logging errors to CONSOLE_LOG.txt
|
||||||
|
- Using current directory if directory has not been given yet.
|
||||||
### [10/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/ffe3839aee6dc1a552d95154d817aefc2b66af81)
|
### [10/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/ffe3839aee6dc1a552d95154d817aefc2b66af81)
|
||||||
- Added support for *self* post
|
- Added support for *self* post
|
||||||
- Now getting posts is quicker
|
- Now getting posts is quicker
|
||||||
|
|||||||
15
script.py
15
script.py
@@ -6,17 +6,19 @@ saved posts from a reddit account. It is written in Python 3.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from io import StringIO
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
|
|
||||||
from src.downloader import Direct, Gfycat, Imgur, Self
|
from src.downloader import Direct, Gfycat, Imgur, Self
|
||||||
|
from src.errors import *
|
||||||
from src.parser import LinkDesigner
|
from src.parser import LinkDesigner
|
||||||
from src.searcher import getPosts
|
from src.searcher import getPosts
|
||||||
from src.tools import (GLOBAL, createLogFile, jsonFile, nameCorrector,
|
from src.tools import (GLOBAL, createLogFile, jsonFile, nameCorrector,
|
||||||
printToFile)
|
printToFile)
|
||||||
from src.errors import *
|
|
||||||
|
|
||||||
__author__ = "Ali Parlakci"
|
__author__ = "Ali Parlakci"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
@@ -637,11 +639,22 @@ def main():
|
|||||||
download(POSTS)
|
download(POSTS)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
log_stream = StringIO()
|
||||||
|
logging.basicConfig(stream=log_stream, level=logging.INFO)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
VanillaPrint = print
|
VanillaPrint = print
|
||||||
print = printToFile
|
print = printToFile
|
||||||
GLOBAL.RUN_TIME = time.time()
|
GLOBAL.RUN_TIME = time.time()
|
||||||
main()
|
main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
if GLOBAL.directory is None:
|
||||||
|
GLOBAL.directory = Path(".\\")
|
||||||
print("\nQUITTING...")
|
print("\nQUITTING...")
|
||||||
quit()
|
quit()
|
||||||
|
except Exception as exception:
|
||||||
|
logging.error("Runtime error!", exc_info=full_exc_info(sys.exc_info()))
|
||||||
|
print(log_stream.getvalue())
|
||||||
|
|
||||||
|
input("Press enter to quit\n")
|
||||||
|
|||||||
@@ -1,3 +1,36 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
class FauxTb(object):
|
||||||
|
def __init__(self, tb_frame, tb_lineno, tb_next):
|
||||||
|
self.tb_frame = tb_frame
|
||||||
|
self.tb_lineno = tb_lineno
|
||||||
|
self.tb_next = tb_next
|
||||||
|
|
||||||
|
def current_stack(skip=0):
|
||||||
|
try: 1/0
|
||||||
|
except ZeroDivisionError:
|
||||||
|
f = sys.exc_info()[2].tb_frame
|
||||||
|
for i in range(skip + 2):
|
||||||
|
f = f.f_back
|
||||||
|
lst = []
|
||||||
|
while f is not None:
|
||||||
|
lst.append((f, f.f_lineno))
|
||||||
|
f = f.f_back
|
||||||
|
return lst
|
||||||
|
|
||||||
|
def extend_traceback(tb, stack):
|
||||||
|
"""Extend traceback with stack info."""
|
||||||
|
head = tb
|
||||||
|
for tb_frame, tb_lineno in stack:
|
||||||
|
head = FauxTb(tb_frame, tb_lineno, head)
|
||||||
|
return head
|
||||||
|
|
||||||
|
def full_exc_info(exc_info):
|
||||||
|
"""Like sys.exc_info, but includes the full traceback."""
|
||||||
|
t, v, tb = exc_info
|
||||||
|
full_tb = extend_traceback(tb, current_stack(1))
|
||||||
|
return t, v, full_tb
|
||||||
|
|
||||||
class RedditLoginFailed(Exception):
|
class RedditLoginFailed(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user