Changeset 561
- Timestamp:
- 28-10-11 19:49:36 (20 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
morituri/common/musicbrainzngs.py (modified) (5 diffs)
-
morituri/common/program.py (modified) (2 diffs)
-
morituri/rip/cd.py (modified) (1 diff)
-
morituri/rip/main.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r559 r561 1 2011-10-28 Thomas Vander Stichele <thomas at apestaart dot org> 2 3 * morituri/rip/main.py: 4 * morituri/common/musicbrainzngs.py: 5 * morituri/common/program.py: 6 * morituri/rip/cd.py: 7 Add -R option to rip to record API results for debugging. 8 1 9 2011-10-28 Thomas Vander Stichele <thomas at apestaart dot org> 2 10 -
trunk/morituri/common/musicbrainzngs.py
r560 r561 72 72 def __init__(self): 73 73 self.tracks = [] 74 75 def _record(record, which, name, what): 76 # optionally record to disc as a JSON serialization 77 if record: 78 import json 79 filename = 'morituri.%s.%s.json' % (which, name) 80 handle = open(filename, 'w') 81 handle.write(json.dumps(what)) 82 handle.close() 83 log.info('musicbrainzngs', 'Wrote %s %s to %s', which, name, filename) 74 84 75 85 … … 176 186 177 187 # see http://bugs.musicbrainz.org/browser/python-musicbrainz2/trunk/examples/ripper.py 178 def musicbrainz(discid ):188 def musicbrainz(discid, record=False): 179 189 """ 180 190 Based on a MusicBrainz disc id, get a list of DiscMetadata objects … … 190 200 from morituri.extern.musicbrainzngs import musicbrainz 191 201 192 re sults= []202 ret = [] 193 203 194 204 try: … … 206 216 return None 207 217 208 log.debug('musicbrainz ', 'found %d releases for discid %r',218 log.debug('musicbrainzngs', 'found %d releases for discid %r', 209 219 len(result['disc']['release-list']), 210 220 discid) 221 _record(record, 'releases', discid, result) 211 222 212 223 # Display the returned results to the user. 213 ret = []214 224 215 225 for release in result['disc']['release-list']: … … 222 232 res = musicbrainz.get_release_by_id(release['id'], 223 233 includes=["artists", "artist-credits", "recordings", "discids"]) 234 _record(record, 'release', release['id'], res) 224 235 release = res['release'] 225 236 -
trunk/morituri/common/program.py
r558 r561 53 53 outdir = None 54 54 result = None 55 56 def __init__(self, record=False): 57 """ 58 @param record: whether to record results of API calls for playback. 59 """ 60 self._record = record 55 61 56 62 def _getTableCachePath(self): … … 225 231 for _ in range(0, 4): 226 232 try: 227 metadatas = musicbrainzngs.musicbrainz(mbdiscid) 233 metadatas = musicbrainzngs.musicbrainz(mbdiscid, 234 record=self._record) 228 235 except musicbrainzngs.NotFoundException, e: 229 236 break -
trunk/morituri/rip/cd.py
r549 r561 111 111 112 112 def do(self, args): 113 prog = program.Program( )113 prog = program.Program(record=self.getRootCommand().record) 114 114 runner = task.SyncRunner() 115 115 -
trunk/morituri/rip/main.py
r508 r561 70 70 configure.version, configure.revision) 71 71 72 self.parser.add_option('-R', '--record', 73 action="store_true", dest="record", 74 help="record API requests for playback") 72 75 self.parser.add_option('-v', '--version', 73 76 action="store_true", dest="version", … … 80 83 sys.exit(0) 81 84 85 self.record = options.record 86 82 87 def parse(self, argv): 83 88 log.debug("morituri", "rip %s" % " ".join(argv))
Note: See TracChangeset
for help on using the changeset viewer.
