Recherche avancée

Médias (1)

Mot : - Tags -/pirate bay

Autres articles (107)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

Sur d’autres sites (11593)

  • Python musical bot

    14 juin 2022, par Лагуш Любомир

    I was working on bot for my discord server for 2 hours but still it doesnt work and not even connecting to voice chat

    


    import discord
from discord.ext import commands
from youtube_dl import YoutubeDL
YDL_OPTIONS = {'format': 'worstaudio/best', 'noplaylist': 'False', 'simulate': 'True',
               'preferredquality': '192', 'preferredcodec': 'mp3', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
client = commands.Bot ( command_prefix='>')
@client.event
async def on_ready():
    print("Meepo connected")
@client.command(pass_context = True )
async def hello( ctx ):
    author = ctx.message.author
    await ctx.send(f"{ author.mention }///Добрий день шановне панство, Я пан Міпарний!")
@client.command()
async def play(ctx, *, arg):
    vc = await ctx.message.author.voice.channel.connect()

    with YoutubeDL(YDL_OPTIONS) as ydl:
        if 'https://' in arg:
            info = ydl.extract_info(arg, download=False)
        else:
            info = ydl.extract_info(f"ytsearch:{arg}", download=False)['entries'][0]

    url = info['formats'][0]['url']

    vc.play(discord.FFmpegPCMAudio(executable="ffmpeg\\bin\\ffmpeg.exe", source=url, **FFMPEG_OPTIONS))
token = open("token.txt", "r").readline()
client.run(token)


    


    in my server console i was getting this message
M

    


    eepo connected
Ignoring exception in command play:
Traceback (most recent call last):
  File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\orest\Desktop\server\bot.py", line 17, in play
    vc = await ctx.message.author.voice.channel.connect()
  File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\abc.py", line 1277, in connect
    voice = cls(client, self)
  File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\voice_client.py", line 199, in __init__
    raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\orest\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice


    


    i cant really understand whats wrong, is there something with my code or i need more Python packages ?

    


  • Running ffmpeg on cmd works, but integrating it with PHP gives out an error

    11 juin 2022, par digiboy

    Running ffmpeg to covert files to mp4 works normally when ran from a command line prompt, but
upon trying to integrate it into a php code I keep getting errors and I am not sure why that is. The error says :

    


    '-i' is not recognized as an internal or external command,
operable program or batch file.
Upload failed 


    


    This is the function that is responsible for running ffmpeg code that converts the file :

    


      public function convertVideoToMp4($tempFilePath, $finalFilePath) {&#xA;    $cmd = "$this->ffmpegPath -i $tempFilePath $finalFilePath 2>&amp;1";&#xA;&#xA;    $outputLog = array();&#xA;    exec($cmd, $outputLog, $returnCode);&#xA;&#xA;    if($returnCode != 0) {&#xA;        //Command failed&#xA;        foreach($outputLog as $line) {&#xA;            echo $line . "<br />";&#xA;        }&#xA;        return false;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;

    &#xA;

    and since my code is returning an error pointing to a command line command being faulty, I am guessing it is triggering the echo $line . "<br />"; from the function above.&#xA;However, right under this error output, I have an error Upload failed&#xA;which points to a different function in the program, mainly the one responsible for the upload of the file itself :

    &#xA;

    if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {&#xA;        $finalFilePath = $targetDir . uniqid() . ".mp4";&#xA;&#xA;        if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {&#xA;            echo "Insert query failed\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        if(!$this->convertVideoToMp4($tempFilePath, $finalFilePath)) {&#xA;            echo "Upload failed\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        if(!$this->deleteFile($tempFilePath)) {&#xA;            echo "Upload failed\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        if(!$this->generateThumbnails($finalFilePath)) {&#xA;            echo "Upload failed - could not generate thumbnails\n";&#xA;            return false;&#xA;        }&#xA;&#xA;    }&#xA;

    &#xA;

    But even though I get the output saying Upload failed, my file DOES get transfered into the folder that is dedicated as the "Upload folder" but the file is NOT converted from flv to mp4 before being uploaded, so I am left very confused.

    &#xA;

    For those who are wondering what the whole code looks like, this is VideoProcessor.php :

    &#xA;

    &lt;?php&#xA;class VideoProcessor {&#xA;&#xA;    private $con;&#xA;    private $sizeLimit = 500000000;&#xA;    private $allowedTypes = array("mp4", "flv", "webm", "mkv", "vob", "ogv", "ogg", "avi", "wmv", "mov", "mpeg", "mpg");&#xA;&#xA;    private $ffmpegPath;&#xA;&#xA;    private $ffprobePath;&#xA;&#xA;    public function __construct($con) {&#xA;        $this->con = $con;&#xA;        $this->ffmpegPath = realpath("C:\Program Files\ffmpeg\bin\ffmpeg");&#xA;        $this->ffprobePath = realpath("C:\Program Files\ffmpeg\bin\ffprobe");&#xA;&#xA;    }&#xA;&#xA;    public function upload($videoUploadData) {&#xA;&#xA;        $targetDir = "uploads/videos/";&#xA;        $videoData = $videoUploadData->videoDataArray;&#xA;&#xA;        $tempFilePath = $targetDir . uniqid() . basename($videoData["name"]);&#xA;        $tempFilePath = str_replace(" ", "_", $tempFilePath);&#xA;&#xA;        $isValidData = $this->processData($videoData, $tempFilePath);&#xA;&#xA;        if(!$isValidData) {&#xA;            return false;&#xA;        }&#xA;&#xA;        if(move_uploaded_file($videoData["tmp_name"], $tempFilePath)) {&#xA;            $finalFilePath = $targetDir . uniqid() . ".mp4";&#xA;&#xA;            if(!$this->insertVideoData($videoUploadData, $finalFilePath)) {&#xA;                echo "Insert query failed\n";&#xA;                return false;&#xA;            }&#xA;&#xA;            if(!$this->convertVideoToMp4($tempFilePath, $finalFilePath)) {&#xA;                echo "Upload failed\n";&#xA;                return false;&#xA;            }&#xA;&#xA;            if(!$this->deleteFile($tempFilePath)) {&#xA;                echo "Upload failed\n";&#xA;                return false;&#xA;            }&#xA;&#xA;            if(!$this->generateThumbnails($finalFilePath)) {&#xA;                echo "Upload failed - could not generate thumbnails\n";&#xA;                return false;&#xA;            }&#xA;&#xA;        }&#xA;    }&#xA;&#xA;    private function processData($videoData, $filePath) {&#xA;        $videoType = pathInfo($filePath, PATHINFO_EXTENSION);&#xA;&#xA;        if(!$this->isValidSize($videoData)) {&#xA;            echo "File too large. Can&#x27;t be more than " . $this->sizeLimit . " bytes";&#xA;            return false;&#xA;        }&#xA;        else if(!$this->isValidType($videoType)) {&#xA;            echo "Invalid file type";&#xA;            return false;&#xA;        }&#xA;        else if($this->hasError($videoData)) {&#xA;            echo "Error code: " . $videoData["error"];&#xA;            return false;&#xA;        }&#xA;&#xA;        return true;&#xA;    }&#xA;&#xA;    private function isValidSize($data) {&#xA;        return $data["size"] &lt;= $this->sizeLimit;&#xA;    }&#xA;&#xA;    private function isValidType($type) {&#xA;        $lowercased = strtolower($type);&#xA;        return in_array($lowercased, $this->allowedTypes);&#xA;    }&#xA;&#xA;    private function hasError($data) {&#xA;        return $data["error"] != 0;&#xA;    }&#xA;&#xA;    private function insertVideoData($uploadData, $filePath) {&#xA;        $query = $this->con->prepare("INSERT INTO videos(title, uploadedBy, description, privacy, category, filePath)&#xA;                                        VALUES(:title, :uploadedBy, :description, :privacy, :category, :filePath)");&#xA;&#xA;        $query->bindParam(":title", $uploadData->title);&#xA;        $query->bindParam(":uploadedBy", $uploadData->uploadedBy);&#xA;        $query->bindParam(":description", $uploadData->description);&#xA;        $query->bindParam(":privacy", $uploadData->privacy);&#xA;        $query->bindParam(":category", $uploadData->category);&#xA;        $query->bindParam(":filePath", $filePath);&#xA;&#xA;        return $query->execute();&#xA;    }&#xA;&#xA;    public function convertVideoToMp4($tempFilePath, $finalFilePath) {&#xA;        $cmd = "$this->ffmpegPath -i $tempFilePath $finalFilePath 2>&amp;1";&#xA;&#xA;        $outputLog = array();&#xA;        exec($cmd, $outputLog, $returnCode);&#xA;&#xA;        if($returnCode != 0) {&#xA;            //Command failed&#xA;            foreach($outputLog as $line) {&#xA;                echo $line . "<br />";&#xA;            }&#xA;            return false;&#xA;        }&#xA;&#xA;        return true;&#xA;    }&#xA;&#xA;    private function deleteFile($filePath) {&#xA;        if(!unlink($filePath)) {&#xA;            echo "Could not delete file\n";&#xA;            return false;&#xA;        }&#xA;&#xA;        return true;&#xA;    }&#xA;&#xA;    public function generateThumbnails($filePath) {&#xA;&#xA;        $thumbnailSize = "210x118";&#xA;        $numThumbnails = 3;&#xA;        $pathToThumbnail = "uploads/videos/thumbnails";&#xA;&#xA;        $duration = $this->getVideoDuration($filePath);&#xA;&#xA;        echo "duration: $duration";&#xA;    }&#xA;&#xA;    private function getVideoDuration($filePath) {&#xA;        return shell_exec("$this->ffprobePath -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $filePath");&#xA;    }&#xA;}&#xA;?>&#xA;

    &#xA;

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

    &#xA;

    What have I done wrong ?

    &#xA;

    class MusicClass(commands.Cog):&#xA;    #universal attributes&#xA;    YDL_OPTIONS = {&#x27;format&#x27;: &#x27;bestaudio&#x27;, &#x27;noplaylist&#x27;: &#x27;True&#x27;}&#xA;    FFMPEG_OPTIONS = {&#x27;before_options&#x27;: &#x27;-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5&#x27;, &#x27;options&#x27;: &#x27;-vn&#x27;}&#xA;&#xA;    def __init__(self, bot):&#xA;        self.bot = bot&#xA;        self.is_playing = False&#xA;        self.music_queue = [[],&#x27;&#x27;] #[[music1, music2, music3...], channel_obj]&#xA;        self.vc = &#x27;&#x27;&#xA;&#xA;    @commands.command()&#xA;    async def join(self, ctx):&#xA;        if not ctx.message.author.voice:&#xA;            await ctx.send("{} is not connected to a voice channel".format(ctx.message.author.name))&#xA;            return&#xA;        else:&#xA;            channel = ctx.message.author.voice.channel&#xA;        await channel.connect()&#xA;&#xA;    @commands.command()&#xA;    async def leave(self, ctx):&#xA;        voice_client = ctx.message.guild.voice_client&#xA;        if voice_client.is_connected():&#xA;            await voice_client.disconnect()&#xA;        else:&#xA;            await ctx.send("The bot is not connected to a voice channel.")&#xA;    &#xA;    #rtype: list[dict{str:}]&#xA;    #params: search string/web URL, top number of results to show&#xA;    #returns list of top 5 queries and their information&#xA;    def search_yt(self, search_query, num_results = 3):&#xA;        with YoutubeDL(self.YDL_OPTIONS) as ydl:&#xA;            try:&#xA;                top_results = ydl.extract_info(f"ytsearch{num_results}:{search_query}", download=False)[&#x27;entries&#x27;][0:{num_results}]&#xA;                for i in range(len(top_results)):&#xA;                    top_results[i] = {&#xA;                        &#x27;title&#x27;: top_results[i][&#x27;title&#x27;],&#xA;                        &#x27;source&#x27;: top_results[i][&#x27;formats&#x27;][0][&#x27;url&#x27;],&#xA;                        &#x27;channel&#x27;: top_results[i][&#x27;channel&#x27;],&#xA;                        &#x27;duration&#x27;: top_results[i][&#x27;duration&#x27;],&#xA;                        &#x27;url&#x27;: top_results[i][&#x27;webpage_url&#x27;]&#xA;                    }&#xA;            except:&#xA;                print(f&#x27;SEARCH_YT ERROR\t search="{search_query}"&#x27;)&#xA;                return False&#xA;            return top_results&#xA;    &#xA;    #rtype: None&#xA;    #looks at queue, decides whether to play the next song in queue or stop&#xA;    def play_next(self):&#xA;        print(&#x27;called play_next&#x27;)&#xA;        if len(self.music_queue) > 0:&#xA;            self.is_playing = True&#xA;            #assigns url AND removes from queue&#xA;            music_url = self.music_queue[0][0][&#x27;source&#x27;]&#xA;            self.music_queue[0].pop(0)&#xA;            self.vc.play(discord.FFmpegAudio(music_url, **self.FFMPEG_OPTIONS), after = lambda e: self.play_next())&#xA;        else:&#xA;            self.is_playing = False&#xA;&#xA;    #rtype: None&#xA;    #similar to play_next but optimized for first-time playing&#xA;    #checks if a song in queue &#x2B; checks if bot&#x27;s connected, then begins to play&#xA;    async def play_now(self):&#xA;        print(&#x27;called play_now, queue:&#x27;, self.music_queue[0])&#xA;        if len(self.music_queue) > 0:&#xA;            self.is_playing = True&#xA;            music_url = self.music_queue[0][0][&#x27;source&#x27;]&#xA;            if self.vc == &#x27;&#x27; or not self.vc.is_connected():&#xA;                self.vc = await self.music_queue[1].connect()&#xA;            else:&#xA;                print(&#x27;moving to new channel&#x27;)&#xA;                self.vc = await self.bot.move_to(self.music_queue[1])&#xA;            self.music_queue[0].pop(0)&#xA;&#xA;            #######################################################################################################&#xA;            print(&#x27;ERROR HAPPENS RIGHT HERE&#x27;)&#xA;            self.vc.play(discord.FFmpegAudio(music_url, **self.FFMPEG_OPTIONS), after = lambda e: self.play_next())&#xA;            #######################################################################################################&#xA;            &#xA;        else:&#xA;            self.is_playing = False&#xA;&#xA;    @commands.command()&#xA;    #dynamically checks for URL link or search query, then attempts to play&#xA;    async def p(self, ctx, *args):&#xA;        voice_channel = ctx.author.voice.channel&#xA;&#xA;        if voice_channel == None: #not in a VC&#xA;            await ctx.send(&#x27;You have to be in a voice channel first&#x27;)&#xA;            return&#xA;        else: #set channel, search and play music&#xA;            if self.music_queue[1] != voice_channel:&#xA;                self.music_queue[1] = voice_channel&#xA;            if args[0].startswith(&#x27;https://www.youtube.com/watch&#x27;): #search URL&#xA;                #search web_url directly and send object to music queue&#xA;                with YoutubeDL(self.YDL_OPTIONS) as ydl:&#xA;                    try:&#xA;                        print(&#x27;attempting to extract URL:&#x27;, args[0])&#xA;                        music_obj = ydl.extract_info(args[0], download=False)&#xA;                        music_obj = {&#xA;                        &#x27;title&#x27;: music_obj[&#x27;title&#x27;],&#xA;                        &#x27;source&#x27;: music_obj[&#x27;formats&#x27;][0][&#x27;url&#x27;],&#xA;                        &#x27;channel&#x27;: music_obj[&#x27;channel&#x27;],&#xA;                        &#x27;duration&#x27;: music_obj[&#x27;duration&#x27;],&#xA;                        &#x27;url&#x27;: music_obj[&#x27;webpage_url&#x27;]&#xA;                        }&#xA;                        print(&#x27;music object:&#x27;, music_obj)&#xA;                        print(&#x27;appending URL song queue&#x27;)&#xA;                        self.music_queue[0].append(music_obj)&#xA;                    except:&#xA;                        print(&#x27;URL search failed. URL =&#x27;, args[0])&#xA;            else: #search query, display search results, ask for which one, then add to queue&#xA;                num_results = args[len(args)-1] if args[len(args)-1].isdigit() else 3&#xA;                song_list = self.search_yt(&#x27; &#x27;.join(args), num_results)&#xA;            &#xA;            if not self.is_playing:&#xA;                await self.play_now()&#xA;

    &#xA;

    Now my error message...

    &#xA;

    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;