Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (84)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

Sur d’autres sites (8907)

  • Pycord Music Bot : AttributeError : 'FFmpegAudio' object has no attribute '_process'

    5 juin 2022, par Steven Mao

    I've made a discord Cog that should be able to queue up and play music, but I'm getting an error from FFmpeg when I actually try to play the URL. I have found an identical question on StackOverflow, but this user's problem was a random typo. The inputs should all be correct, so I am not sure if the problem is my code or my package.

    


    What have I done wrong ?

    


    class MusicClass(commands.Cog):
    #universal attributes
    YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'}
    FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}

    def __init__(self, bot):
        self.bot = bot
        self.is_playing = False
        self.music_queue = [[],''] #[[music1, music2, music3...], channel_obj]
        self.vc = ''

    @commands.command()
    async def join(self, ctx):
        if not ctx.message.author.voice:
            await ctx.send("{} is not connected to a voice channel".format(ctx.message.author.name))
            return
        else:
            channel = ctx.message.author.voice.channel
        await channel.connect()

    @commands.command()
    async def leave(self, ctx):
        voice_client = ctx.message.guild.voice_client
        if voice_client.is_connected():
            await voice_client.disconnect()
        else:
            await ctx.send("The bot is not connected to a voice channel.")
    
    #rtype: list[dict{str:}]
    #params: search string/web URL, top number of results to show
    #returns list of top 5 queries and their information
    def search_yt(self, search_query, num_results = 3):
        with YoutubeDL(self.YDL_OPTIONS) as ydl:
            try:
                top_results = ydl.extract_info(f"ytsearch{num_results}:{search_query}", download=False)['entries'][0:{num_results}]
                for i in range(len(top_results)):
                    top_results[i] = {
                        'title': top_results[i]['title'],
                        'source': top_results[i]['formats'][0]['url'],
                        'channel': top_results[i]['channel'],
                        'duration': top_results[i]['duration'],
                        'url': top_results[i]['webpage_url']
                    }
            except:
                print(f'SEARCH_YT ERROR\t search="{search_query}"')
                return False
            return top_results
    
    #rtype: None
    #looks at queue, decides whether to play the next song in queue or stop
    def play_next(self):
        print('called play_next')
        if len(self.music_queue) > 0:
            self.is_playing = True
            #assigns url AND removes from queue
            music_url = self.music_queue[0][0]['source']
            self.music_queue[0].pop(0)
            self.vc.play(discord.FFmpegAudio(music_url, **self.FFMPEG_OPTIONS), after = lambda e: self.play_next())
        else:
            self.is_playing = False

    #rtype: None
    #similar to play_next but optimized for first-time playing
    #checks if a song in queue + checks if bot's connected, then begins to play
    async def play_now(self):
        print('called play_now, queue:', self.music_queue[0])
        if len(self.music_queue) > 0:
            self.is_playing = True
            music_url = self.music_queue[0][0]['source']
            if self.vc == '' or not self.vc.is_connected():
                self.vc = await self.music_queue[1].connect()
            else:
                print('moving to new channel')
                self.vc = await self.bot.move_to(self.music_queue[1])
            self.music_queue[0].pop(0)

            #######################################################################################################
            print('ERROR HAPPENS RIGHT HERE')
            self.vc.play(discord.FFmpegAudio(music_url, **self.FFMPEG_OPTIONS), after = lambda e: self.play_next())
            #######################################################################################################
            
        else:
            self.is_playing = False

    @commands.command()
    #dynamically checks for URL link or search query, then attempts to play
    async def p(self, ctx, *args):
        voice_channel = ctx.author.voice.channel

        if voice_channel == None: #not in a VC
            await ctx.send('You have to be in a voice channel first')
            return
        else: #set channel, search and play music
            if self.music_queue[1] != voice_channel:
                self.music_queue[1] = voice_channel
            if args[0].startswith('https://www.youtube.com/watch'): #search URL
                #search web_url directly and send object to music queue
                with YoutubeDL(self.YDL_OPTIONS) as ydl:
                    try:
                        print('attempting to extract URL:', args[0])
                        music_obj = ydl.extract_info(args[0], download=False)
                        music_obj = {
                        'title': music_obj['title'],
                        'source': music_obj['formats'][0]['url'],
                        'channel': music_obj['channel'],
                        'duration': music_obj['duration'],
                        'url': music_obj['webpage_url']
                        }
                        print('music object:', music_obj)
                        print('appending URL song queue')
                        self.music_queue[0].append(music_obj)
                    except:
                        print('URL search failed. URL =', args[0])
            else: #search query, display search results, ask for which one, then add to queue
                num_results = args[len(args)-1] if args[len(args)-1].isdigit() else 3
                song_list = self.search_yt(' '.join(args), num_results)
            
            if not self.is_playing:
                await self.play_now()


    


    Now my error message...

    


    Exception ignored in: <function at="at" 0x7ff4b0a5b5e0="0x7ff4b0a5b5e0">&#xA;Traceback (most recent call last):&#xA;  File "/home/stevenmao/.local/lib/python3.8/site-packages/discord/player.py", line 127, in __del__&#xA;    self.cleanup()&#xA;  File "/home/stevenmao/.local/lib/python3.8/site-packages/discord/player.py", line 247, in cleanup&#xA;    self._kill_process()&#xA;  File "/home/stevenmao/.local/lib/python3.8/site-packages/discord/player.py", line 198, in _kill_process&#xA;    proc = self._process&#xA;AttributeError: &#x27;FFmpegAudio&#x27; object has no attribute &#x27;_process&#x27;&#xA;</function>

    &#xA;

  • discord.py and ffmpeg : Play a sound effect while playing music

    26 juin 2022, par JPhusion

    I would like to play a sound effect while playing music in a vc using discord.py and ffmpeg. I know you cannot play more than one audio source at a time, so instead I am trying to pause the music, play the sound effect and continue the music.

    &#xA;

    This is what I've come up with so far, but because I am playing the sound effect, the resume() method no longer works after the pause().

    &#xA;

    @commands.command()&#xA;    async def sfx(self, ctx):&#xA;        try:&#xA;            voice = await ctx.author.voice.channel.connect()&#xA;        except:&#xA;            voice = ctx.guild.voice_client&#xA;        try:&#xA;            voice.pause()&#xA;            # voice.play(discord.FFmpegPCMAudio(&#x27;./media/sfx/notification.mp3&#x27;))&#xA;        except:&#xA;            voice.pause()&#xA;            # voice.play(discord.FFmpegPCMAudio(executable=r"C:\Users\josh\Programming\Discord\ffmpeg\bin\ffmpeg.exe", source=&#x27;./media/sfx/notification.mp3&#x27;))&#xA;        guild = self.client.get_guild(752756902525403156)&#xA;        member = guild.get_member(876292773639233596)&#xA;        print(member.activities[0].name)&#xA;        await asyncio.sleep(1)&#xA;        voice.resume()&#xA;        if member.activities[0].name == "Not playing music":&#xA;            await voice.disconnect()&#xA;

    &#xA;

  • My bot that I uploaded to heroku doesn't work the music command

    25 août 2022, par Lucas Silva

    I'm creating a bot for discord it works great locally, but after I uploaded it on heroku the music command stopped working I'm using these buildpacksenter image description here

    &#xA;

    The command code is this

    &#xA;

     @commands.command(name="musga", help="coloque um url da musica que deseja reproduzir!")&#xA;async def play(self, ctx, arg):&#xA;    global vc&#xA;    &#xA;    try:&#xA;        voice_channel = ctx.author.voice.channel&#xA;        vc = await voice_channel.connect()&#xA;    except:&#xA;        print(&#x27;[ERROR]&#x27;) #debug&#xA;&#xA;    if vc.is_playing():&#xA;        await ctx.send(f&#x27;{ctx.author.mention}, J&#xE1; estou cantando.&#x27;)&#xA;&#xA;    else:&#xA;        with YoutubeDL(self.YDL_OPTIONS) as ydl:&#xA;            info = ydl.extract_info(arg, download=False)&#xA;        &#xA;        URL = info[&#x27;formats&#x27;][0][&#x27;url&#x27;]&#xA;&#xA;        vc.play(discord.FFmpegPCMAudio(executable="ffmpeg", source = URL, **self.FFMPEG_OPTIONS))&#xA;                &#xA;        while vc.is_playing():&#xA;            await sleep(1)&#xA;

    &#xA;

    in my requirements.txt file I have : discord.py[voice] PyNaCL youtube_dl ffmpeg

    &#xA;

    When I use the command it enters the call but it doesn't play the music and it doesn't return any error.

    &#xA;

    i hope someone can help me. Thanks in advance

    &#xA;