
Recherche avancée
Médias (91)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
avec chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
sans chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
config chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (92)
-
Amélioration de la version de base
13 septembre 2013Jolie 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, parCe 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" ; -
Le profil des utilisateurs
12 avril 2011, parChaque 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 (...)
Sur d’autres sites (9327)
-
How to delete mp3 file after the bot played it
8 mars 2021, par EckigerLucaI am trying to create a music bot and now I want the bot to delete the current playing song after it finished playing. There's my code :


import asyncio

import os
import discord
from discord.embeds import Embed
from discord.file import File
from discord.player import AudioPlayer
from youtube_dl.utils import smuggle_url, update_url_query
from youtube_search import YoutubeSearch
import discord
from discord.ext.commands import bot
import youtube_dl
from discord.ext import commands
from youtube_dl import YoutubeDL

youtube_dl.utils.bug_reports_message = lambda: ''

ytdl_format_options = {
 'format': 'bestaudio/best',
 'outtmpl': '/music_files/%(id)s.mp3',
 'restrictfilenames': True,
 'noplaylist': True,
 'nocheckcertificate': True,
 'ignoreerrors': False,
 'logtostderr': False,
 'quiet': True,
 'no_warnings': True,
 'default_search': 'auto',
 'source_address': '0.0.0.0' 
}

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

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)


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

 self.data = data

 self.title = data.get('title')
 self.thumbnail = data.get('thumbnail')
 self.url = data.get('webpage_url')
 self.uploader = data.get('uploader')
 self.uploader_url = data.get('uploader_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:
 # take first item from a playlist
 data = data['entries'][0]

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

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


 @commands.command()
 async def play(self, ctx, *, url):
 global player
 """Plays from a url (almost anything youtube_dl supports)"""
 async with ctx.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)

 await ctx.send("Started playing!")
 @play.before_invoke
 async def ensure_voice(self, ctx):
 if ctx.voice_client is None:
 if ctx.author.voice:
 await ctx.author.voice.channel.connect()
 else:
 await ctx.send("You are not connected to a voice channel.")
 raise commands.CommandError("Author not connected to a voice channel.")
 elif ctx.voice_client.is_playing():
 ctx.voice_client.stop()

def setup(client):
 client.add_cog(Music(client))



It's saving the files to a folder called "music_files" with the format videoid.mp3
I noticed that it's logging something in the cmd when
logging.basicConfig(level=logging.INFO)
is added to the main.py file under the imports, is there maybe a way to use it ?

Note : The code is a modified version of basic_voice.py by Rapptz.


Edit : I found a way :


folder = './music_files'
 for song in os.listdir(folder):
 file_path = os.path.join(folder, song)
 try:
 if os.path.isfile(file_path) or os.path.islink(file_path):
 os.unlink(file_path)
 elif os.path.isdir(file_path):
 shutil.rmtree(file_path)
 except Exception as e:
 print('Failed to delete %s. Reason %s' % (file_path, e))



-
Example of streaming YouTube audio using FFMPEG
15 avril 2020, par DupeI would like to use FFMPEG to stream YouTube audio to another source



using (var ffmpeg = CreateProcess(track.GetUrl()))
using (var stream = client.CreatePCMStream())
{
 try { await ffmpeg.StandardOutput.BaseStream.CopyToAsync(stream); }
 finally { await stream.FlushAsync(); }
}




Where
CreateProcess()
looks like this :


private Process CreateProcess(string url)
{
 return Process.Start(new ProcessStartInfo
 {
 FileName = "ffmpeg.exe",
 Arguments = $"-hide_banner -loglevel panic -i \"{url}\" -ac 2 -f s16le -ar 48000 pipe:1",
 UseShellExecute = false,
 RedirectStandardOutput = true
 });
}




- 

url
represents the YouTube video URL.client
represents a Discord audio client, to which I want to copy the stream to.- I am using Discord.Net (latest stable).









The arguments do not seem to be correct as there is no playback and no such exception is returned.


-
ffmpeg doesn't see yt_dlp stream
24 décembre 2022, par matiz22I making discord bot and i am trying to move from youtube_dl to yt_dlp to get +18 videos from youtube, I am getting error Output file #0 does not contain any stream.


self.YTDL_OPTIONS = {'format': 'bestaudio', 'nonplaylist': 'True', 'youtube_include_dash_manifest': False}

self.FFMPEG_OPTIONS = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
 'options': '-vn'
}



with YoutubeDL(self.YTDL_OPTIONS) as ydl:
 try:
 info = ydl.extract_info(url, download=False)
 except:
 return False
return {
 'link': 'https://www.youtube.com/watch?v=' + url,
 'thumbnail': 'https://i.ytimg.com/vi/' + url + '/hqdefault.jpg?sqp=-oaymwEcCOADEI4CSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLD5uL4xKN-IUfez6KIW_j5y70mlig',
 'source': info['formats'][0]['url'],
 'title': info['title']
}



self.vc[id].play(discord.FFmpegPCMAudio(
 song['source'], **self.FFMPEG_OPTIONS), after=lambda e: self.play_next(interaction))



This config works with youtube_dl, but not with yt_dlp. Any ideas what i should change ?