Exemple #1
0
    def enqueue(self, location):
        metadata = song_utils.gather_metadata(location)

        last = self.last()
        index = 1 if last is None else last.index + 1
        song = self.create(index=index, **metadata)
        return song
Exemple #2
0
    def get_new_song_location(self, search_text, downloader, ip, archive=True):
        location = downloader.fetch()

        metadata = song_utils.gather_metadata(location)

        with transaction.atomic():
            queryset = ArchivedSong.objects.filter(url=metadata['url'])
            if queryset.count() == 0:
                initial_counter = 1 if archive else 0
                archived_song = ArchivedSong.objects.create(
                    url=metadata['url'],
                    artist=metadata['artist'],
                    title=metadata['title'],
                    counter=initial_counter)
            else:
                if archive:
                    queryset.update(counter=F('counter') + 1)
                archived_song = queryset.get()

            if archive:
                ArchivedQuery.objects.get_or_create(song=archived_song,
                                                    query=search_text)

        if archive and self.musiq.base.settings.logging_enabled:
            RequestLog.objects.create(song=archived_song, address=ip)
        return location
Exemple #3
0
    def enqueue(self, location, manually_requested):
        metadata = song_utils.gather_metadata(location)

        last = self.last()
        index = 1 if last is None else last.index + 1
        song = self.create(index=index,
                           manually_requested=manually_requested,
                           url=metadata['url'],
                           artist=metadata['artist'],
                           title=metadata['title'],
                           duration=metadata['duration'])
        return song
Exemple #4
0
    def _archive(self, location, query):
        metadata = song_utils.gather_metadata(location)

        with transaction.atomic():
            queryset = ArchivedSong.objects.filter(url=metadata['url'])
            if queryset.count() == 0:
                archived_song = ArchivedSong.objects.create(
                    url=metadata['url'],
                    artist=metadata['artist'],
                    title=metadata['title'],
                    counter=1)
            else:
                queryset.update(counter=F('counter') + 1)
                archived_song = queryset.get()

            ArchivedQuery.objects.get_or_create(song=archived_song,
                                                query=query)
        return archived_song