def export_songs(self, songids): __settings__ = xbmcaddon.Addon("webinterface.qooxtunes") export_folder = __settings__.getSetting("export_folder") if export_folder == "": print "[export_songs] export folder not set; exiting" return False db = xbmcdb.songdb() songs = db.get_songs(songids) song_file_paths = [] for s in songs: if len(s.files) > 0: song_file_paths.append(s.files[0]) print "[export_songs] exporting files to '" + export_folder + "'..." exporter = file_exporter.file_exporter() print "[export_songs] created exporter object..." if exporter.export(export_folder, song_file_paths): print "[export_songs] done." return True else: print "[export_songs] error occurred during export: " + exporter.get_error_message() return False
def save_multiple_tracks(self, media_type, track_ids, changes): print "[save_multiple_tracks] <%s>\n" % (media_type) if media_type == "music": db = xbmcdb.songdb() db.save_multiple_songs(track_ids, changes) return
def export_songs(self, songids): __settings__ = xbmcaddon.Addon('webinterface.qooxtunes') export_folder = __settings__.getSetting('export_folder') if (export_folder == ''): print "[export_songs] export folder not set; exiting" return False db = xbmcdb.songdb() songs = db.get_songs(songids) song_file_paths = [] for s in songs: if len(s.files) > 0: song_file_paths.append(s.files[0]) print "[export_songs] exporting files to '" + export_folder + "'..." exporter = file_exporter.file_exporter() print "[export_songs] created exporter object..." if (exporter.export(export_folder, song_file_paths)): print "[export_songs] done." return True else: print "[export_songs] error occurred during export: " + exporter.get_error_message( ) return False
def save_multiple_tracks(self, media_type, track_ids, changes): print "[save_multiple_tracks] <%s>\n" % (media_type) if media_type == 'music': db = xbmcdb.songdb() db.save_multiple_songs(track_ids, changes) return
def set_tracks (self, songids): if (self.media_type == 'music'): db = xbmcdb.songdb () db_tracks = db.get_songs (songids) track_lookup = {} for t in db_tracks: track_lookup[t.id] = t self.tracks = [] for id in songids: if id in track_lookup: t = track_lookup[id] self.tracks.append (t)
def set_tracks(self, songids): if (self.media_type == 'music'): db = xbmcdb.songdb() db_tracks = db.get_songs(songids) track_lookup = {} for t in db_tracks: track_lookup[t.id] = t self.tracks = [] for id in songids: if id in track_lookup: t = track_lookup[id] self.tracks.append(t)
def download_songs(self, download_id): try: songids = self._get_songids(download_id) except IOError as e: self.log_message( "[download_songs] could not load songids from pickled object") self.send_response(404) self.send_CORS_headers() self.end_headers() return download_filename = "qooxtunes-" + download_id + ".zip" self.send_response(200) self.send_CORS_headers() self.send_header('Content-type', 'application/zip') self.send_header('Content-Disposition', 'attachment; filename="%s"' % download_filename) self.end_headers() self.log_message("songids: %s\n" % songids) db = xbmcdb.songdb() songs = db.get_songs(songids) song_file_paths = [] for s in songs: if len(s.files) > 0: song_file_paths.append(s.files[0]) self.log_message("writing zip stream...") self.log_message("file mode: " + self.wfile.mode) for data in zipstream2.ZipStream(song_file_paths, "qooxtunes-" + download_id, zipstream2.ZIP_STORED): self.wfile.write(data) self.wfile.flush() self.wfile.flush() self.log_message("done.") return
def download_songs(self, download_id): try: songids = self._get_songids(download_id) except IOError as e: self.log_message("[download_songs] could not load songids from pickled object") self.send_response(404) self.send_CORS_headers() self.end_headers() return download_filename = "qooxtunes-" + download_id + ".zip" self.send_response(200) self.send_CORS_headers() self.send_header("Content-type", "application/zip") self.send_header("Content-Disposition", 'attachment; filename="%s"' % download_filename) self.end_headers() self.log_message("songids: %s\n" % songids) db = xbmcdb.songdb() songs = db.get_songs(songids) song_file_paths = [] for s in songs: if len(s.files) > 0: song_file_paths.append(s.files[0]) self.log_message("writing zip stream...") self.log_message("file mode: " + self.wfile.mode) for data in zipstream2.ZipStream(song_file_paths, "qooxtunes-" + download_id, zipstream2.ZIP_STORED): self.wfile.write(data) self.wfile.flush() self.wfile.flush() self.log_message("done.") return
t.title = title t.duration = duration t.files.append(string.strip(line)) print "[m3u.get_tracks] - " + t.files[0].encode( 'utf-8') + "..." tracks.append(t) duration = 0 title = '' line = infile.readline() infile.close() if self.media_type == 'music': print "[m3u.get_tracks] looking up song ids..." db = xbmcdb.songdb() db.lookup_m3u_tracks(tracks) return tracks if __name__ == "__main__": import sys import codecs if (len(sys.argv) != 2): print "Usage: script infile.m3u" sys.exit(1) try: m = m3u(sys.argv[1]) tracks = m.get_tracks()