Пример #1
0
    def find_tracks_by_url(self, url):
        logging.debug("Search By URL")

        index = url.rfind("#")
        if index > 0:
            url = url[:index]
        index = url.find("id=")
        if index < 0:
            return None

        id = url[index + 3:]
        id = int(id)
        if id > 0:
            results = self.get_result('audio.get', "uid=" + str(id))
        else:
            results = self.get_result('audio.get', "gid=" + str(abs(id)))

        childs = []
        for line in results:
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url']
            bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
            childs.append(bean)

        return childs
Пример #2
0
    def find_tracks_by_url(self, url):
        logging.debug("Search By URL")

        index = url.rfind("#")
        if index > 0:
            url = url[:index]
        index = url.find("id=")
        if index < 0:
            return None

        id = url[index + 3:]
        id = int(id)
        if id > 0:
            results = self.get_result('audio.get', "uid=" + str(id))
        else:
            results = self.get_result('audio.get', "gid=" + str(abs(id)))

        childs = []
        for line in results:
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url'].replace("https://", "http://")
            bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
            childs.append(bean)

        return childs
Пример #3
0
    def get_common_beans(self):
        beans = []
        cue = self.parse()
        if not self.is_cue_valid():
            return []
        for i, track  in enumerate(cue.tracks):
            bean = FModel(text=track.performer + " - " + track.title, path=track.path)
            bean.artist = track.performer
            bean.tracknumber = i + 1
            bean.title = track.title
            bean.album = self.cue_file.title
            bean.name = bean.text
            bean.start_sec = track.get_start_time_sec()
            bean.duration_sec = track.duration
            bean.time = convert_seconds_to_text(track.duration)
            bean.is_file = True
            try:
                bean.info = foobnix.util.id3_util.normalized_info(get_mutagen_audio(track.path).info, bean)
            except Exception, e:
                logging.warn(str(e) + " " + bean.path)
                bean.info = ""

            if not bean.title or not bean.artist:
                bean = udpate_id3(bean)

            beans.append(bean)
Пример #4
0
 def find_track_by_id(self, id):
     result = self.get_result("audio.get", "audios=" + str(id))
     if not result:
         return None
     line = result[0]
     bean = FModel(line['artist'] + ' - ' + line['title'])
     bean.aritst = line['artist']
     bean.title = line['title']
     bean.time = convert_seconds_to_text(line['duration'])
     bean.path = line['url']
     bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
     return bean
Пример #5
0
 def find_track_by_id(self, id):
     result = self.get_result("audio.get", "audios=" + str(id))
     if not result:
         return None
     line = result[0]
     bean = FModel(line['artist'] + ' - ' + line['title'])
     bean.aritst = line['artist']
     bean.title = line['title']
     bean.time = convert_seconds_to_text(line['duration'])
     bean.path = line['url']
     bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
     return bean
Пример #6
0
 def find_track_by_id(self, id):
     if id is not None:
         parts = id.split("_")
         result = self.get_result("audio.get", "owner_id=%s&audio_ids=%s" % (str(parts[0]), str(parts[1])))
         line = result[1]
     else:
         result = self.get_result("audio.get", "audios=" + str(id))
         line = result[0]
     if not result:
         return None
     bean = FModel(line['artist'] + ' - ' + line['title'])
     bean.aritst = line['artist']
     bean.title = line['title']
     bean.time = convert_seconds_to_text(line['duration'])
     bean.path = line['url'].replace("https://", "http://")
     bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
     return bean
Пример #7
0
 def get_user_tracks_as_beans(self, user_id):
     beans = []
     result = self.controls.vk_service.get_result('audio.get', "uid=" + user_id)
     if not result:
         beans = [FDModel(_("No results found")).add_is_file(True)]
     else:
         for line in result:
             bean = FModel(line['artist'] + ' - ' + line['title'])
             bean.aritst = line['artist']
             bean.title = line['title']
             bean.time = convert_seconds_to_text(line['duration'])
             bean.path = line['url']
             bean.aid = line['aid']
             bean.oid = line['owner_id']
             bean.is_file = True
             bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
             beans.append(bean)
     return beans
Пример #8
0
 def get_user_tracks_as_beans(self, user_id):
     beans = []
     result = self.controls.vk_service.get_result('audio.get',
                                                  "uid=" + user_id)
     if not result:
         beans = [FDModel(_("No results found")).add_is_file(True)]
     else:
         for line in result:
             bean = FModel(line['artist'] + ' - ' + line['title'])
             bean.aritst = line['artist']
             bean.title = line['title']
             bean.time = convert_seconds_to_text(line['duration'])
             bean.path = line['url']
             bean.aid = line['aid']
             bean.oid = line['owner_id']
             bean.is_file = True
             bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
             beans.append(bean)
     return beans
Пример #9
0
 def find_track_by_id(self, id):
     if id is not None:
         parts = id.split("_")
         result = self.get_result(
             "audio.get",
             "owner_id=%s&audio_ids=%s" % (str(parts[0]), str(parts[1])))
         line = result[1]
     else:
         result = self.get_result("audio.get", "audios=" + str(id))
         line = result[0]
     if not result:
         return None
     bean = FModel(line['artist'] + ' - ' + line['title'])
     bean.aritst = line['artist']
     bean.title = line['title']
     bean.time = convert_seconds_to_text(line['duration'])
     bean.path = line['url'].replace("https://", "http://")
     bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
     return bean
Пример #10
0
    def find_tracks_by_query(self, query):
        logging.info("start search songs " + query)
        query = urllib.quote(query.encode("utf-8"))

        list = self.get_result("audio.search", "q=" + query)
        childs = []

        if not list:
            return childs

        for line in list[1:]:
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url'].replace("https://", "http://")
            bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
            childs.append(bean)

        return childs
Пример #11
0
    def find_tracks_by_query(self, query):
        logging.info("start search songs " + query)
        query = urllib.quote(query.encode("utf-8"))

        list = self.get_result("audio.search", "q=" + query)
        childs = []

        if not list:
            return childs

        for line in list[1:]:
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url']
            bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
            childs.append(bean)

        return childs