Mercurial > audlegacy
annotate contrib/lap.py @ 3336:904c58081f0a trunk
removed Disconnect method and Disconnected signal as they have been removed from the spec.
author | Ben Tucker <ben.tucker@gmail.com> |
---|---|
date | Sat, 11 Aug 2007 22:17:13 -0700 |
parents | 3c3a3f3c2269 |
children | 7a4fcf84a34f |
rev | line source |
---|---|
3255
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
1 #!/usr/bin/env python |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
2 """Locate and Play |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
3 Author: Stephan Sokolow (deitarion/SSokolow) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
4 License: GNU GPL-2 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
5 Version: 1.0 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
6 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
7 Description: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
8 - A quick wrapper to make playing songs via the local command quick and easy. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
9 - Works with any player which implements the MPRIS standard for remote control via D-Bus. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
10 - Accepts multiple space- and/or comma-separated choices after presenting the results. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
11 - Can enqueue or enqueue and play. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
12 - Can show full paths or just filenames. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
13 - Will behave in a sane fashion when asked to enqueue and play multiple files. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
14 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
15 TODO: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
16 - Complete the list of extensions for ModPlug, Embedded MPlayer (plugins-ugly), and UADE (3rd-party) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
17 - Support sticking a 'q' in the result to choose enqueue on the fly |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
18 - Support an "all" keyword and an alternative to Ctrl+C for cancelling. (maybe 0) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
19 """ |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
20 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
21 ADLIB_EXTS = ['.a2m', '.adl', '.adlib', '.amd', '.bam', '.cff', '.cmf', '.d00', '.dfm', '.dmo', '.dro', '.dtm', '.hsc', '.hsp', |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
22 '.jbm', '.ksm', '.laa', '.lds', '.m', '.mad', '.mkj', '.msc', '.mtk', '.rad', '.raw', '.rix', '.rol', '.sat', |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
23 '.sa2', '.sci', '.sng', '.imf', '.wlf', '.xad', '.xsm'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
24 CONSOLE_EXTS = ['.adx', '.ay', '.gbs', '.gym', '.hes', '.kss', '.minipsf', '.nsf', '.nsfe', '.psf', '.sap', '.sid', '.spc', |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
25 '.vgm', '.vgz', '.vtx', '.ym'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
26 MIDI_EXTS = ['.mid', '.midi', '.rmi'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
27 MODULE_EXTS = [ '.it', ',mod', '.s3m', '.stm', '.xm'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
28 PLAYLIST_EXTS = ['.cue', '.m3u', '.pls', '.xspf'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
29 WAVEFORM_EXTS = ['.aac', '.aif', '.aiff', '.au', '.flac', '.m4a', '.mp2', '.mp3', '.mpc', '.ogg', '.snd', '.tta', '.voc', '.wav', |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
30 '.wma', '.wv'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
31 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
32 # Edit these lines to choose the kind of files to be filtered for. By default, playlist extensions are excluded. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
33 OK_EXTS = WAVEFORM_EXTS + MODULE_EXTS + CONSOLE_EXTS + MIDI_EXTS + ADLIB_EXTS |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
34 # If you want true format filtering, YOU write the mimetype cache. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
35 USE_PAGER = False # Should we page output if it's more than a screenful? |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
36 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
37 locate_command = ['locate', '-i'] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
38 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
39 # ========== Configuration Ends ========== |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
40 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
41 import fnmatch, optparse, os, subprocess |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
42 from dbus import Bus, DBusException |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
43 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
44 # Use readline if available but don't depend on it |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
45 try: import readline |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
46 except ImportError: pass |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
47 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
48 # connect to DBus |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
49 bus = Bus(Bus.TYPE_SESSION) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
50 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
51 def get_results(query): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
52 """Given a query or series of queries for the locate command, run them.""" |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
53 results, cmd = [], locate_command + (isinstance(query, basestring) and [query] or query) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
54 for line in subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
55 result = line.strip() |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
56 if os.path.splitext(result)[1] in OK_EXTS: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
57 results.append(result) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
58 results.sort() |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
59 return results |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
60 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
61 def filter(results, filters): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
62 for filter in filters: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
63 results = [x for x in results if fnmatch.fnmatch(x.lower(), '*%s*' % filter.lower())] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
64 return results |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
65 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
66 def makeMenu(results, strip_path=True): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
67 for pos, val in enumerate(results): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
68 val = strip_path and os.path.split(val)[1] or val |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
69 print "%3d) %s" % (pos+1, val) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
70 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
71 def addTrack(path, play=False): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
72 try: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
73 mp = bus.get_object('org.freedesktop.MediaPlayer', '/TrackList') |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
74 mp.AddTrack('file://' + path, play) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
75 except DBusException: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
76 print "ERROR: Unable to contact media player." |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
77 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
78 def parseChoice(inString): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
79 try: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
80 return [int(inString)] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
81 except ValueError: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
82 choices = [] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
83 for x in inString.replace(',',' ').split(): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
84 try: choices.append(int(x)) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
85 except ValueError: print "Not an integer: %s" % x |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
86 return choices |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
87 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
88 if __name__ == '__main__': |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
89 try: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
90 op = optparse.OptionParser() |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
91 op.add_option("-q", "--enqueue", action="store_true", dest="enqueue", default=False, |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
92 help="Don't start the song playing after enqueueing it.") |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
93 op.add_option("-p", "--show_path", action="store_true", dest="show_path", default=False, |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
94 help="Show the full path to each result.") |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
95 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
96 (opts, args) = op.parse_args() |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
97 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
98 results = (len(args) > 0) and get_results(args.pop(0)) or [] |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
99 results = filter(results, args) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
100 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
101 def takeChoice(index, play=False): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
102 index = index - 1 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
103 if index >= 0 and index < len(results): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
104 addTrack(results[index], play) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
105 else: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
106 print "Invalid result index: %s" % (index + 1) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
107 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
108 if len(results): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
109 makeMenu(results, not opts.show_path) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
110 choices = parseChoice(raw_input("Choice(s) (Ctrl+C to cancel): ")) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
111 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
112 if len(choices): |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
113 takeChoice(choices.pop(0), not opts.enqueue) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
114 for item in choices: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
115 takeChoice(item, False) # This ensures proper behaviour with no --enqueue and multiple choices. |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
116 else: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
117 print "No Results" |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
118 except KeyboardInterrupt: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
diff
changeset
|
119 pass |