1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

Made imports consistent, made default work

This commit is contained in:
Brad Horrocks 2014-04-16 12:32:43 -06:00
parent 7765830490
commit 64bce14b21

View File

@ -5,14 +5,14 @@ import webbrowser
import urllib
import urllib2
import re
import ConfigParser, os
import os
import ConfigParser
import string
import random
from HTMLParser import HTMLParser
import argparse
from pprint import pprint
class NoRedirection(urllib2.HTTPErrorProcessor):
def http_response(self, request, response):
@ -51,15 +51,15 @@ class MyHTMLParser(HTMLParser):
def main():
# new ConfigParser
config = ConfigParser.ConfigParser()
# defaults
# default options so we dont die later
config.add_section('SaveToFile')
config.set('SaveToFile', 'enabled', False)
config.set('SaveToFile', 'directory', '~/Dropbox/pirate-get/')
# load user settings
# load user options, to override default ones
config.read([os.path.expanduser('~/.config/pirate-get/pirate.cfg')])
parser = argparse.ArgumentParser(description='Finds and downloads torrents from the Pirate Bay')
@ -234,7 +234,7 @@ def main():
choices = ()
if config.get('SaveToFile', 'enabled'):
# Save to file is enabled
fileName = os.path.expanduser(config.get('SaveToFile', 'directory')) + id_generator() + '.magnet'
print ("Saving to File: " + fileName)
f = open(fileName, 'w')
@ -246,6 +246,11 @@ def main():
f.close()
else:
# use transmission as default
for choice in choices:
choice = int(choice)
url = mags[choice][0]
print(url)
if args.transmission:
os.system("""transmission-remote --add "%s" """ % (url))
os.system("transmission-remote -l")