Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (63)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • 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 (...)

Sur d’autres sites (6451)

  • Discord music bot doesn't play songs

    9 octobre 2023, par Gam3rsCZ

    I have made myself a discord bot that also plays music(it's only for my server so strings with messages are in Czech, but code is in English).
Bot worked a while ago but now it stopped, and I don't know where the problem is

    


    I'm getting these errors : HTTP error 403 Forbidden Server returned 403 Forbidden (access denied) and
C :\Users\Me\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\player.py:711 : RuntimeWarning : coroutine 'music_cog.play_next' was never awaited
self.after(error)
RuntimeWarning : Enable tracemalloc to get the object allocation traceback
[2023-10-09 16:23:47] [INFO ] discord.player : ffmpeg process 17496 successfully terminated with return code of 1.
INFO : ffmpeg process 17496 successfully terminated with return code of 1.

    


    My code is :

    


    import discord
from discord.ext import commands
from yt_dlp import YoutubeDL

class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

        self.is_playing = False
        self.is_paused = False
        self.current = ""

        self.music_queue = []
        self.YDL_OPTIONS = {"format": "m4a/bestaudio/best", "noplaylist": "True"}
        self.FFMPEG_OPTIONS = {"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", "options": "-vn"}

        self.vc = None

    def search_yt(self, item):
        with YoutubeDL(self.YDL_OPTIONS) as ydl:
            try:
                info = ydl.extract_info("ytsearch:%s" % item, download=False)["entries"][0]
            except Exception:
                return False
        info = ydl.sanitize_info(info)
        url = info['url']
        title = info['title']
        return {'title': title, 'source': url}

    async def play_next(self):
        if len(self.music_queue) > 0:
            self.is_playing = True
            self.current = self.music_queue[0][0]["title"]
            m_url = self.music_queue[0][0]["source"]

            self.music_queue.pop(0)

            await self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e:  self.play_next())
        else:
            self.is_playing = False

    async def play_music(self, ctx):
        try:
            if len(self.music_queue) > 0:
                self.is_playing = True
                m_url = self.music_queue[0][0]["source"]

                if self.vc == None or not self.vc.is_connected():
                    self.vc =  await self.music_queue[0][1].connect()

                    if self.vc == None:
                        await ctx.send("Nepodařilo se připojit do hlasového kanálu.")
                        return
                else:
                    await self.vc.move_to(self.music_queue[0][1])

                self.current = self.music_queue[0][0]["title"]
                self.music_queue.pop(0)

                self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
            else:
                self.is_playing = False

        except:
            print("Something went wrong")
            await ctx.send(content="Něco se pokazilo")

    @commands.command(name="play", help="Plays selected song from YouTube")
    async def play(self, ctx, *args):
        query = " ".join(args)

        voice_channel = ctx.author.voice.channel
        if voice_channel is None:
            await ctx.send("Připojte se do hlasového kanálu!")
        elif self.is_paused:
            self.vc.resume()
        else:
            song = self.search_yt(query)
            if type(song) == type(True):
                await ctx.send("Písničku se nepodařilo stáhnout. Špatný formát, možná jste se pokusili zadat playlist nebo livestream.")
            else:
                await ctx.send("Písnička přidána do řady.")
                self.music_queue.append([song, voice_channel])

                if self.is_playing == False:
                    await self.play_music(ctx)
                    self.is_playing = True

    @commands.command(name="pause", aliases=["p"], help="Pauses the BOT")
    async def pause(self, ctx, *args):
        if self.is_playing:
            self.is_playing = False
            self.is_paused = True
            self.vc.pause()
            await ctx.send(content="Písnička byla pozastavena.")
            
        elif self.is_paused:
            self.is_playing = True
            self.is_paused = False
            self.vc.resume()
            await ctx.send(content="Písnička byla obnovena.")

    @commands.command(name="resume", aliases=["r"], help="Resumes playing")
    async def resume(self, ctx, *args):
        if self.is_paused:
            self.is_paused = False
            self.is_playing = True
            self.vc.resume()
            await ctx.send(content="Písnička byla obnovena.")

    @commands.command(name="skip", aliases=["s"], help="Skips current song")
    async def skip(self, ctx, *args):
        if self.vc != None and self.vc:
            self.vc.stop()
        await self.play_next()
        await ctx.send(content="Písnička byla přeskočena.")

    @commands.command(name="queue", aliases=["q"], help="Displays song queue")
    async def queue(self, ctx, songs=5):
        retval = ""

        for i in range(0, len(self.music_queue)):
            if i > songs: break
            retval += "    " + self.music_queue[i][0]["title"] + "\n"

        if retval != "":
            retval += "```"
            await ctx.send(content=("```Aktuální fronta:\n" + retval))
        else:
            await ctx.send("Řada je prázdná.")

    @commands.command(name="clear", help="Clears the queue")
    async def clear(self, ctx):
        if self.vc != None and self.is_playing:
            self.vc.stop()
        self.music_queue = []
        await ctx.send("Řada byla vymazána.")

    @commands.command(name="leave", aliases=["dc", "disconnect"], help="Disconnects the BOT")
    async def leave(self, ctx):
        self.is_playing = False
        self.is_paused = False

        if self.vc != None:
            return await self.vc.disconnect(), await ctx.send(content="BOT byl odpojen.")

        else:
            return await ctx.send("BOT není nikde připojen.")
   
    @commands.command(name="current", help="Displays the current song")
    async def current(self, ctx):
        current = self.current
        retval = f"```Právě hraje:\n    {current}```"
        if current != "":
            await ctx.send(retval)
        else:
            await ctx.send("Aktuálně nic nehraje.")


    


    I already tried everything I can think of(which isn't a lot because I suck at programming), and also tried searching for some solution on the internet, but nothing worked.

    


  • My music doesn't play correctly and other problems - Discord.py

    24 mars 2021, par Diacono

    So, I'm triying to let my bot play songs directly from the url (without downloading them like the song.mp3 method) but I'm having a hard time. The bot plays only 1 song and when I try to play another song it doesn't play it.
I'm also getting 2 errors : video_link is not defined and self is not defined.
Also when I try to play live music like "lofi hip hop radio - beats to relax/study to" nothing happens.
Can you help me please ???

    


    This is my code

    


    import asyncio
import discord
from discord.ext import commands, tasks
import requests
import json
from random import choice
from discord.utils import get
from discord import FFmpegPCMAudio
import youtube_dl
bot = commands.Bot(command_prefix="!")



ytdl_format_options = {
    'format': 'bestaudio/best',
    'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
    'restrictfilenames': True,
    'noplaylist': True,
    'nocheckcertificate': True,
    'ignoreerrors': False,
    'logtostderr': False,
    'quiet': True,
    'no_warnings': True,
    'default_search': 'auto',
    'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
}

ffmpeg_options = {
    'options': '-vn'
}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

class YTDLSource(discord.PCMVolumeTransformer):
    def __init__(self, source, *, data, volume=0.5):
        super().__init__(source, volume)

        self.data = data

        self.title = data.get('title')
        self.url = data.get('url')

    @classmethod
    async def from_url(cls, url, *, loop=None, stream=False):
        loop = loop or asyncio.get_event_loop()
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download= not stream))

        if 'entries' in data:
            data = data['entries'][0]

        filename = data['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)


@bot.command()
async def play(ctx, url):
    voice = await ctx.author.voice.channel.connect()
    player = await YTDLSource.from_url(url, loop=client.loop)
    ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
    ydl_opts = {'format': 'bestaudio'}
    FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
         info = ydl.extract_info(video_link, download=False)
         URL = info['formats'][0]['url']
    voice = get(self.bot.voice_clients, guild=ctx.guild)
    voice.play(discord.FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))


    


  • Convert m4a to aac and keep metadata on Windows 7

    24 novembre 2014, par betamax

    I want to convert an m4a file to aac*. I can do this using :

    ffmpeg -i song.m4a -acodec copy song.aac

    But on Windows 7 the metadata is not compatible. It seems the -id3v2_version 3 flag should be used so that Windows compatible ID3 tags version 2.3 are used :

    ffmpeg -i song.m4a -acodec copy -id3v2_version 3 song.aac

    However, with the above command I still don’t get any metadata in song.aac. I have used windows file explorer, mp3tag and winamp to confirm there are no tags.

    * : reason ; m4a won’t play on the car stereo so following this advice (http://www.vwaudiforum.co.uk/forum/showthread.php?153728-Tip-Getting-M4A-(iTunes)-format-music-to-play-on-a-VW-head-unit)

    Console Output :

    C:\temp>ffmpeg -i song.m4a -acodec copy -id3v2_version 3 song.aac
    ffmpeg version N-67914-gf87a344 Copyright (c) 2000-2014 the FFmpeg developers
     built on Nov 22 2014 22:10:18 with gcc 4.9.2 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi
    g --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
    enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-lib
    opencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
    r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
    enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
    libx265 --enable-libxavs --enable-libxvid --enable-zlib
     libavutil      54. 15.100 / 54. 15.100
     libavcodec     56. 13.100 / 56. 13.100
     libavformat    56. 15.100 / 56. 15.100
     libavdevice    56.  3.100 / 56.  3.100
     libavfilter     5.  2.103 /  5.  2.103
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002dcc760] stream 0, timescale not set
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'song.m4a':
     Metadata:
       major_brand     : M4A
       minor_version   : 0
       compatible_brands: M4A mp42isom
       creation_time   : 1980-07-20 13:32:00
       iTunSMPB        :  00000000 00000840 0000007C 0000000001027F44 00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000
       iTunNORM        :  0000061A 0000052A 00001C40 000021EE 00035E0A 00046912 00007B8C 00007B99 0002845B 00024D35
       title           : Time Away
       artist          : Andy Stott
       album_artist    : Andy Stott
       album           : Faith In Strangers
       genre           : Electronic
       track           : 1/9
       disc            : 1/1
       compilation     : 0
       gapless_playback: 0
       date            : 2014-11-17T08:00:00Z
       copyright       : Ôäù 2014 Modern Love
       media_type      : 1
       iTunMOVI        : <?xml version="1.0" encoding="UTF-8"?>
                       :
                       : <plist version="1.0">
                       : <dict>
                       :   <key>asset-info</key>
                       :   <dict>
                       :           <key>file-size</key>
                       :           <integer>14359364</integer>
                       :           <key>flavor</key>
                       :           <string>2:256</string>
                       :   </dict>
                       : </dict>
                       : </plist>
                       :
     Duration: 00:06:24.20, start: 0.000000, bitrate: 298 kb/s
       Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 285 kb/s (default)
       Metadata:
         creation_time   : 1980-07-20 13:32:00
       Stream #0:1: Video: mjpeg, gray(bt470bg/unknown/unknown), 1400x1400 [SAR 300:300 DAR 1:1], 90k tbr, 90k tbn, 90k tbc

    Output #0, adts, to 'song.aac':
     Metadata:
       major_brand     : M4A
       minor_version   : 0
       compatible_brands: M4A mp42isom
       iTunMOVI        : &lt;?xml version="1.0" encoding="UTF-8"?>
                       :
                       : <plist version="1.0">
                       : <dict>
                       :   <key>asset-info</key>
                       :   <dict>
                       :           <key>file-size</key>
                       :           <integer>14359364</integer>
                       :           <key>flavor</key>
                       :           <string>2:256</string>
                       :   </dict>
                       : </dict>
                       : </plist>
                       :
       iTunSMPB        :  00000000 00000840 0000007C 0000000001027F44 00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000
       iTunNORM        :  0000061A 0000052A 00001C40 000021EE 00035E0A 00046912 00007B8C 00007B99 0002845B 00024D35
       title           : Time Away
       artist          : Andy Stott
       album_artist    : Andy Stott
       album           : Faith In Strangers
       genre           : Electronic
       track           : 1/9
       disc            : 1/1
       compilation     : 0
       gapless_playback: 0
       date            : 2014-11-17T08:00:00Z
       copyright       : Ôäù 2014 Modern Love
       media_type      : 1
       encoder         : Lavf56.15.100
       Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 285 kb/s (default)
       Metadata:
         creation_time   : 1980-07-20 13:32:00
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
    Press [q] to stop, [?] for help
    size=   13523kB time=00:06:24.19 bitrate= 288.3kbits/s
    video:0kB audio:13410kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.843272%

    C:\temp>