Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit ea5f1b3

Browse files
committed
Fix a bug by removing categories
1 parent 28995ea commit ea5f1b3

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

uget-chrome-wrapper/bin/uget-chrome-wrapper

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@
1919
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2020

2121
# sudo apt install python3-urllib3
22-
import argparse, struct, sys, threading, logging, json, urllib, subprocess, tempfile
22+
import struct, sys, threading, logging, json, urllib, subprocess, tempfile
2323
from urllib.parse import urlparse
2424
from urllib.request import urlopen
2525
from os.path import splitext, basename, join, expanduser
2626
from mimetypes import guess_extension
2727

2828
cookie_filepath = join(tempfile.gettempdir(), 'uget_cookie')
2929
UGET_COMMAND = "uget-gtk"
30-
UGET_CATEGORY_DIR = join(expanduser('~'), '.config/uGet/category')
3130
VERSION = "2.0.4"
3231

3332
logger = logging.getLogger()
34-
# log_file_path = join(expanduser('~'), 'uget-chrome-wrapper.log')
35-
# logging.basicConfig(format='%(asctime)s [%(levelname)s]: %(message)s', filename=log_file_path, filemode='a', level=logging.DEBUG)
33+
log_file_path = join(expanduser('~'), 'uget-chrome-wrapper.log')
34+
logging.basicConfig(format='%(asctime)s [%(levelname)s]: %(message)s', filename=log_file_path, filemode='a', level=logging.DEBUG)
3635
logger.propagate = False
3736

3837
# Platform specific configuration
@@ -42,7 +41,6 @@ if sys.platform == 'win32':
4241
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
4342
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
4443
UGET_COMMAND = 'uget'
45-
UGET_CATEGORY_DIR = join(expanduser('~'), 'AppData\\Local\\uGet\\category')
4644

4745
def extract_file_name(url):
4846
fileName = ''
@@ -127,7 +125,7 @@ def read_message():
127125
pass
128126
if not filename:
129127
filename = extract_file_name(url)
130-
128+
131129
# Add the referer url
132130
if referer:
133131
command.append("--http-referer=" + referer)
@@ -155,42 +153,5 @@ def read_message():
155153
sys.exit(0)
156154

157155

158-
def download_category(fileName):
159-
"""
160-
Download the category from the repository and store in the config folder.
161-
"""
162-
downloads_directory = join(expanduser('~'), 'Downloads')
163-
url = 'https://raw.githubusercontent.com/slgobinath/uget-chrome-wrapper/master/config/category/' + fileName
164-
with urlopen(url) as response:
165-
data = json.loads(response.read().decode('utf-8'))
166-
data['info']['common']['folder'] = join(downloads_directory, data['info']['common']['folder'])
167-
168-
category_file = join(UGET_CATEGORY_DIR, fileName)
169-
logger.debug('Writing to ' + str(category_file))
170-
with open(category_file, 'w') as outfile:
171-
json.dump(data, outfile, indent=4)
172-
173-
def add_categories():
174-
"""
175-
Download and add the categories to the uGet config directory.
176-
"""
177-
for index in range(1, 7):
178-
print('000{}.json'.format(index))
179-
download_category('000{}.json'.format(index))
180-
181-
def Main():
182-
read_message()
183-
184-
185156
if __name__ == '__main__':
186-
parser = argparse.ArgumentParser()
187-
parser.add_argument("-c", "--categorize", help="create new categories based on the file types", action="store_true")
188-
parser.add_argument("-v", "--version", help="display the version of uget-chrome-wrapper and exit", action="store_true")
189-
args = parser.parse_args()
190-
191-
if args.version:
192-
print('uget-chrome-wrapper {}'.format(VERSION))
193-
elif args.categorize:
194-
add_categories()
195-
else:
196-
Main()
157+
read_message()

0 commit comments

Comments
 (0)