def from_search(self, search_term, content_type, direction=None, output_name=None, output_type=None): options = Options() result = self.spotify.search(search_term, limit=50) self.log(message=f'Searched for "{search_term}"', function='from_search', data=result) if not result: return None # build objectpath query & get first result tree_obj = objectpath.Tree(result) search_mod = '.album' if options.type_is_album(content_type) else '' query = f'$.tracks.items{search_mod}.(name, uri)' queried = json.loads(json.dumps(tuple(tree_obj.execute(query))))[0] options.parent_name = queried['name'] reference = queried['uri'] options.generate(reference=reference, direction=direction, content_type=content_type, output_name=output_name, output_type=output_type) return self.samplify(options)
def current_song(self, direction=None, output_name=None, output_type=None): """API for E2E rip of sample data from current song playing""" # scope required? options = Options() options.generate(reference=None, direction=direction, content_type=options.CURRENT_SONG, output_name=output_name, output_type=output_type) return self.samplify(options)
def song(self, reference, direction=None, output_name=None, output_type=None): """API for E2E rip of sample data from song""" options = Options() options.generate(reference=reference, direction=direction, content_type=options.SONG, output_name=output_name, output_type=output_type) return self.samplify(options)
def playlist(self, reference, direction=None, output_name=None, output_type=None, username=None): options = Options() options.generate(reference=reference, direction=direction, content_type=options.PLAYLIST, output_name=output_name, output_type=output_type, username=username) return self.samplify(options)