
Recherche avancée
Autres articles (104)
-
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
ANNEXE : Les plugins utilisés spécifiquement pour la ferme
5 mars 2010, parLe site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)
Sur d’autres sites (4715)
-
How do I make my discord bot play music by using youtubedl's search function instead of url ? (Python)
28 septembre 2021, par PypypieYumI want it to search for the video and play it, how can i change the following code to achieve that ? Every time I use the ytsearch function in ytdl, I notice that it only searches for the first word of the title and download it, however, it causes error later on and do nothing.


@commands.command()
 async def play(self, ctx, url):
 if ctx.author.voice is None:
 await ctx.send("You are not in a voice channel!")
 voice_channel = ctx.author.voice.channel
 if ctx.voice_client is None:
 await voice_channel.connect()
 else:
 await ctx.voice_client.move_to(voice_channel)

 ctx.voice_client.stop()
 FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
 YDL_OPTIONS = {'format':"bestaudio", 'default_search':"ytsearch"}
 vc = ctx.voice_client

 with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
 info = ydl.extract_info(url, download=False)
 if 'entries' in info:
 url2 = info["entries"][0]["formats"][0]
 elif 'formats' in info:
 url2 = info["formats"][0]['url']
 source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
 vc.play(source)



And this is the error message :


Ignoring exception in command play:
Traceback (most recent call last):
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "/home/runner/HandmadeLivelyLines/music.py", line 44, in play
 source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 387, in from_probe
 return cls(source, bitrate=bitrate, codec=codec, **kwargs)
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 324, in __init__
 super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 138, in __init__
 self._process = self._spawn_process(args, **kwargs)
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 144, in _spawn_process
 process = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, **subprocess_kwargs)
 File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
 self._execute_child(args, executable, preexec_fn, close_fds,
 File "/usr/lib/python3.8/subprocess.py", line 1639, in _execute_child
 self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not dict

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

Traceback (most recent call last):
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
 await ctx.command.invoke(ctx)
 File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "/opt/virtualenvs/python3/lib/python3.8/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: TypeError: expected str, bytes or os.PathLike object, not dict



Thanks.


-
Pycord Music Bot : AttributeError : 'FFmpegAudio' object has no attribute '_process'
5 juin 2022, par Steven MaoI'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">
Traceback (most recent call last):
 File "/home/stevenmao/.local/lib/python3.8/site-packages/discord/player.py", line 127, in __del__
 self.cleanup()
 File "/home/stevenmao/.local/lib/python3.8/site-packages/discord/player.py", line 247, in cleanup
 self._kill_process()
 File "/home/stevenmao/.local/lib/python3.8/site-packages/discord/player.py", line 198, in _kill_process
 proc = self._process
AttributeError: 'FFmpegAudio' object has no attribute '_process'
</function>


-
discord.py and ffmpeg : Play a sound effect while playing music
26 juin 2022, par JPhusionI 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.


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


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