Skip to content

Commit

Permalink
add browser option, close #15
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyJD committed Dec 2, 2012
1 parent 2f36bcf commit 48e57c3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions isrcsubmit.py
Expand Up @@ -165,6 +165,7 @@ def gatherOptions(argv):
# this default is only for libdiscid and mediatools # this default is only for libdiscid and mediatools
else: else:
defaultDevice = "/dev/cdrom" defaultDevice = "/dev/cdrom"
defaultBrowser = "firefox"
prog = scriptname prog = scriptname
parser = OptionParser(version=scriptVersion(), add_help_option=False) parser = OptionParser(version=scriptVersion(), add_help_option=False)
parser.set_usage("%s [options] [user] [device]\n %s -h" % (prog, prog)) parser.set_usage("%s [options] [user] [device]\n %s -h" % (prog, prog))
Expand All @@ -182,6 +183,8 @@ def gatherOptions(argv):
help="Force using a specifig backend to extract ISRCs from the" help="Force using a specifig backend to extract ISRCs from the"
+ " disc. Possible backends are: %s." % ", ".join(backends) + " disc. Possible backends are: %s." % ", ".join(backends)
+ " They are tried in this order otherwise." ) + " They are tried in this order otherwise." )
parser.add_option("--browser", metavar="BROWSER",
help="Program to open urls. The default is " + defaultBrowser)
parser.add_option("--debug", action="store_true", default=False, parser.add_option("--debug", action="store_true", default=False,
help="Show debug messages." help="Show debug messages."
+ " Currently shows some backend messages.") + " Currently shows some backend messages.")
Expand All @@ -204,6 +207,8 @@ def gatherOptions(argv):
# Mac: device is changed again, when we know the final backend # Mac: device is changed again, when we know the final backend
# Win: cdrdao is not given a device and will try 0,1,0 # Win: cdrdao is not given a device and will try 0,1,0
options.device = defaultDevice options.device = defaultDevice
if options.browser is None:
options.browser = defaultBrowser
if len(args) > 0: if len(args) > 0:
print "WARNING: Superfluous arguments:", ", ".join(args) print "WARNING: Superfluous arguments:", ", ".join(args)
if options.backend and not hasBackend(options.backend, strict=True): if options.backend and not hasBackend(options.backend, strict=True):
Expand Down Expand Up @@ -442,12 +447,13 @@ def getRelease(self, submit=False):
if self._release is None: if self._release is None:
if submit: if submit:
url = self.submissionUrl url = self.submissionUrl
print "Would you like to open Firefox to submit the disc?", print "Would you like to open the browser to submit the disc?",
if raw_input("[y/N] ") == "y": if raw_input("[y/N] ") == "y":
try: try:
os.execlp('firefox', 'firefox', url) os.execlp(options.browser, options.browser, url)
except OSError, e: except OSError, e:
printError("Couldn't open the url in firefox:", str(e)) printError("Couldn't open the url in %s:"
% (options.browser, str(e)))
printError2("Please submit it via:", url) printError2("Please submit it via:", url)
sys.exit(1) sys.exit(1)
else: else:
Expand Down Expand Up @@ -640,8 +646,8 @@ def cleanupIsrcs(isrcs):
print print


url = "http://musicbrainz.org/isrc/" + isrc url = "http://musicbrainz.org/isrc/" + isrc
if raw_input("Open ISRC in firefox? [Y/n] ") != "n": if raw_input("Open ISRC in the browser? [Y/n] ") != "n":
Popen(["firefox", url]) Popen([options.browser, url])
raw_input("(press <return> when done with this ISRC) ") raw_input("(press <return> when done with this ISRC) ")




Expand Down Expand Up @@ -809,12 +815,13 @@ def cleanupIsrcs(isrcs):
url = releaseId + "/discids" # The "releaseId" is an url itself url = releaseId + "/discids" # The "releaseId" is an url itself
print "This url would provide some info about the disc IDs:" print "This url would provide some info about the disc IDs:"
print url print url
print "Would you like to open it in Firefox?", print "Would you like to open it the browser?",
if raw_input("[y/N] ") == "y": if raw_input("[y/N] ") == "y":
try: try:
Popen(['firefox', url]) Popen([options.browser, url])
except OSError, e: except OSError, e:
printError("Couldn't open the url in firefox:", str(e)) printError("Couldn't open the url with %s: %s"
% (options.browser, str(e)))


trackOffset = askForOffset(disc.trackCount, releaseTrackCount) trackOffset = askForOffset(disc.trackCount, releaseTrackCount)
else: else:
Expand Down

0 comments on commit 48e57c3

Please sign in to comment.