Exemple #1
0
    async def delete_all(self, ctx):
        """Delete pending songs from autoplaylist"""
        delete_songs = set(read_lines(DELETE_AUTOPLAYLIST))

        _songs = read_lines(AUTOPLAYLIST)
        songs = set(_songs)
        duplicates = len(_songs) - len(songs)

        failed = 0
        succeeded = 0
        for song in delete_songs:
            try:
                songs.remove(song)
                succeeded += 1
            except KeyError as e:
                failed += 1
                terminal.exception('Failed to delete all from autoplaylist')

        write_playlist(AUTOPLAYLIST, songs)

        empty_file(DELETE_AUTOPLAYLIST)

        await ctx.send(
            'Successfully deleted {0} songs, {1} duplicates and failed {2}'.
            format(succeeded, duplicates, failed))
Exemple #2
0
    async def add_from_playlist(self, name, channel=None):
        if channel is None:
            channel = self.channel

        lines = read_lines(os.path.join(self.playlist_path, name))
        if lines is None:
            return await self.send('Invalid playlist name', channel=channel)

        await self.send('Processing {} songs'.format(len(lines)), delete_after=60, channel=channel)
        for line in lines:
            await self._add_url(line, no_message=True)

        await self.send('Enqueued %s' % name, channel=channel)
Exemple #3
0
def delete_from_ap(deleted_vids):
    songs = set(read_lines(AUTOPLAYLIST))
    changed = False
    for song in deleted_vids:
        try:
            songs.remove(song)
            changed = True

        except KeyError:
            pass

    if not changed:
        return

    write_playlist(AUTOPLAYLIST, songs)
Exemple #4
0
    async def add_all(self, ctx):
        """Add the pending songs to autoplaylist"""
        songs = set(read_lines(ADD_AUTOPLAYLIST))

        invalid = []
        for song in list(songs):
            if not test_url(song):
                songs.remove(song)
                invalid.append(song)

        if invalid:
            await ctx.send('Invalid url(s):\n%s' % ', '.join(invalid),
                           delete_after=40)

        write_playlist(AUTOPLAYLIST, songs, mode='a')
        empty_file(ADD_AUTOPLAYLIST)

        amount = len(songs)
        await ctx.send('Added %s song(s) to autoplaylist' % amount)
Exemple #5
0
 def _get_playlist(self, name):
     playlist = os.path.join(self.playlist_path, name)
     lines = read_lines(playlist)
     return lines
Exemple #6
0
 def reload_gachilist(self):
     self.bot.gachilist = read_lines(os.path.join(PLAYLISTS, 'gachi.txt'))
     self.gachilist = self.bot.gachilist
Exemple #7
0
def delete_from_list(deleted_vids):
    songs = set(read_lines(gachilist))
    songs = songs - set(deleted_vids)
    write_playlist(gachilist, songs)