Beispiel #1
0
def main(parent_id, *files):
	parent_id = int(parent_id)
	with MediaTransfer() as mtp:
		try:
			for source in files:
				print('Sending track {}'.format(source))
				metadata = dict([(n.lower(), v, ) for n, v in id3tags(source).as_dict().items()])
				target = 'Music/' + basename(source)
				metadata = mtp.send_track_from_file(source, target, parent_id=parent_id, **metadata)
				print('Created new track with metadata: {}'.format(metadata))
		except:
			for n in mtp.get_errorstack():
				print('{errornumber}: {error_text}'.format(**n))
			raise
Beispiel #2
0
def upload_track(mtp, parent_id, source):
	metadata = dict([(n.lower(), v, ) for n, v in id3tags(source).as_dict().items()])
	metadata = mtp.send_track_from_file(source, 'Music/' + basename(source), parent_id=parent_id, **metadata)
	print("Created new track with ID: {object_id}".format(**metadata))
	return metadata['object_id']