
Recherche avancée
Autres articles (56)
-
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...) -
Le plugin : Podcasts.
14 juillet 2010, parLe problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
Types de fichiers supportés dans les flux
Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)
Sur d’autres sites (7578)
-
New cookie behaviour in browsers may cause regressions
24 février 2020, par Matomo Core Team — Community, DevelopmentLast year the Chromium browser team announced they would change their default behaviour for cookies. In particular about a property called
samesite
. Over the last few months, we have made various changes to our cookie handling to get Matomo ready for this. Depending on your setup and the features you use, some things may not work anymore.You can avoid most of the issues by using HTTPS on your Matomo, and ideally also use HTTPS on your website(s).
If you are not running the latest version of Matomo yet (3.13.3 at the time of writing), then we highly recommend that you upgrade as soon as possible. Previous versions are not compatible with these cookie browser changes.
Opt out screen
If you embed the opt out screen on your website running on HTTP, there is a chance the Matomo opt out no longer works. In these cases it may still work over http:
- when the privacy policy page that embeds the opt out screen (via iframe) also has the Matomo JavaScript tracker embedded,
- and when both the opt out and the JS tracker point to the same Matomo installation.
In other cases when HTTP is used, the opt out feature will likely be broken.
We recommend you test whether the opt out on your site still works by opening your privacy policy page in an incognito browser window. Then test to opt out of tracking, and then reload the page. If the checkbox “You are not opted out. Uncheck this box to opt out.” is still ticked, then your opt out is not working.
If the opt out is not working anymore, it is most likely due to HTTP being used. In that case you should change the opt out URL to HTTPS. For example change from
<iframe src=”<strong>http://</strong>…”
to<iframe src=”<strong>https://</strong>...”
. If your Matomo doesn’t support HTTPS yet, you will need to contact your webhoster or system administrator to get SSL enabled on your Matomo domain.JavaScript tracker
In most cases, everything related to the JavaScript Tracker will still work as expected.
But there is an edge case : when you are also reading Matomo’s cookie server side. You may be affected by this edge case issue when :
- you track part of the user behaviour in the browser (using Matomo JS Tracker),
- and also track user behavior in your server (for example using one of Matomo SDKs in PHP, Java, Python, C#, etc.).
In that case, for you to still be able to read the so-called
visitorId
on your server, we recommend you add this line to your JS tracking code :_paq.push([‘setSecureCookie’, location.protocol === 'https:']);
The cookie can be only retrieved if your website is loaded through HTTPS.
Should you have any questions, or notice anything isn’t working as expected, please visit our forum.
Third party cookies
If you are using third party cookies, using HTTPS on your Matomo is now a requirement to make them work across different domains. Otherwise Chrome and in the near future other browsers would not accept the cookie. If you don’t know if you are using third party cookies or first party cookies, you’re likely using first party cookies and this does not affect you.
-
"FFmpeg : Error not transitioning to the next song in Discord Bot's queue."
1er avril 2024, par nooberI have 3 modules, but I'm sure the error occurs within this module, and here is the entire code within that module :


import asyncio
import discord
from discord import FFmpegOpusAudio, Embed
import os

async def handle_help(message):
 embed = discord.Embed(
 title="Danh sách lệnh cho Bé Mèo",
 description="Dưới đây là các lệnh mà chủ nhân có thể bắt Bé Mèo phục vụ:",
 color=discord.Color.blue()
 )
 embed.add_field(name="!play", value="Phát một bài hát từ YouTube.", inline=False)
 embed.add_field(name="!pause", value="Tạm dừng bài hát đang phát.", inline=False)
 embed.add_field(name="!resume", value="Tiếp tục bài hát đang bị tạm dừng.", inline=False)
 embed.add_field(name="!skip", value="Chuyển đến bài hát tiếp theo trong danh sách chờ.", inline=False)
 embed.add_field(name="!stop", value="Dừng phát nhạc và cho phép Bé Mèo đi ngủ tiếp.", inline=False)
 # Thêm các lệnh khác theo cùng mẫu trên
 await message.channel.send(embed=embed)

class Song:
 def __init__(self, title, player):
 self.title = title # Lưu trữ tiêu đề bài hát ở đây
 self.player = player

# Thêm đối tượng Song vào hàng đợi
def add_song_to_queue(guild_id, queues, song):
 queues.setdefault(guild_id, []).append(song)

async def handle_list(message, queues):
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 if os.path.exists(log_file_path):
 with open(log_file_path, "r", encoding="utf-8") as f:
 song_list = f.readlines()

 if song_list:
 embed = discord.Embed(
 title="Danh sách bài hát",
 description="Danh sách các bài hát đã phát:",
 color=discord.Color.blue()
 )

 for i, song in enumerate(song_list, start=1):
 if i == 1:
 song = "- Đang phát: " + song.strip()
 embed.add_field(name=f"Bài hát {i}", value=song, inline=False)

 await message.channel.send(embed=embed)
 else:
 await message.channel.send("Hiện không có dữ liệu trong file log.")
 else:
 await message.channel.send("File log không tồn tại.")

async def handle_commands(message, client, queues, voice_clients, yt_dl_options, ytdl, ffmpeg_options=None, guild_id=None, data=None):
 # Nếu không có ffmpeg_options, sử dụng các thiết lập mặc định
 if ffmpeg_options is None:
 ffmpeg_options = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
 'options': '-vn -filter:a "volume=0.25"'
 }
 
 # Khởi tạo voice_client
 if guild_id is None:
 guild_id = message.guild.id

 if guild_id in voice_clients:
 voice_client = voice_clients[guild_id]
 else:
 voice_client = None

 # Xử lý lệnh !play
 if message.content.startswith("!play"):
 try:
 # Kiểm tra xem người gửi tin nhắn có đang ở trong kênh voice không
 voice_channel = message.author.voice.channel
 # Kiểm tra xem bot có đang ở trong kênh voice của guild không
 if voice_client and voice_client.is_connected():
 await voice_client.move_to(voice_channel)
 else:
 voice_client = await voice_channel.connect()
 voice_clients[guild_id] = voice_client
 except Exception as e:
 print(e)

 try:
 query = ' '.join(message.content.split()[1:])
 if query.startswith('http'):
 url = query
 else:
 query = 'ytsearch:' + query
 loop = asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(query, download=False))
 if not data:
 raise ValueError("Không có dữ liệu trả về từ YouTube.")
 url = data['entries'][0]['url']

 player = FFmpegOpusAudio(url, **ffmpeg_options)
 # Lấy thông tin của bài hát mới đang được yêu cầu
 title = data['entries'][0]['title']
 duration = data['entries'][0]['duration']
 creator = data['entries'][0]['creator'] if 'creator' in data['entries'][0] else "Unknown"
 requester = message.author.nick if message.author.nick else message.author.name
 
 # Tạo embed để thông báo thông tin bài hát mới
 embed = discord.Embed(
 title="Thông tin bài hát mới",
 description=f"**Bài hát:** *{title}*\n**Thời lượng:** *{duration}*\n**Tác giả:** *{creator}*\n**Người yêu cầu:** *{requester}*",
 color=discord.Color.green()
 )
 await message.channel.send(embed=embed)
 
 # Sau khi lấy thông tin của bài hát diễn ra, gọi hàm log_song_title với title của bài hát
 # Ví dụ:
 title = data['entries'][0]['title']
 await log_song_title(title)

 # Thêm vào danh sách chờ nếu có bài hát đang phát
 if voice_client.is_playing():
 queues.setdefault(guild_id, []).append(player)
 else:
 voice_client.play(player)
 
 except Exception as e:
 print(e)
 
 if message.content.startswith("!link"):
 try:
 voice_client = await message.author.voice.channel.connect()
 voice_clients[voice_client.guild.id] = voice_client
 except Exception as e:
 print(e)

 try:
 url = message.content.split()[1]

 loop = asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

 song = data['url']
 player = discord.FFmpegOpusAudio(song, **ffmpeg_options)

 voice_clients[message.guild.id].play(player)
 except Exception as e:
 print(e)

 # Xử lý lệnh !queue
 elif message.content.startswith("!queue"):
 queue = queues.get(guild_id, [])
 if queue:
 await message.channel.send("Danh sách chờ:")
 for index, item in enumerate(queue, 1):
 await message.channel.send(f"{index}. {item.title}")
 else:
 await message.channel.send("Không có bài hát nào trong danh sách chờ.")

 # Xử lý lệnh !skip
 elif message.content.startswith("!skip"):
 try:
 if voice_client and voice_client.is_playing():
 voice_client.stop()
 await play_next_song(guild_id, queues, voice_client, skip=True)
 await remove_first_line_from_log()
 except Exception as e:
 print(e)

 # Xử lý các lệnh như !pause, !resume, !stop
 elif message.content.startswith("!pause"):
 try:
 if voice_client and voice_client.is_playing():
 voice_client.pause()
 except Exception as e:
 print(e)

 elif message.content.startswith("!resume"):
 try:
 if voice_client and not voice_client.is_playing():
 voice_client.resume()
 except Exception as e:
 print(e)

 elif message.content.startswith("!stop"):
 try:
 if voice_client:
 voice_client.stop()
 await voice_client.disconnect()
 del voice_clients[guild_id] # Xóa voice_client sau khi dừng
 except Exception as e:
 print(e)

async def log_song_title(title):
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 try:
 # Kiểm tra xem tệp tin log đã tồn tại chưa
 if not os.path.exists(log_file_path):
 # Nếu chưa tồn tại, tạo tệp tin mới và ghi title vào tệp tin đó
 with open(log_file_path, 'w', encoding='utf-8') as file:
 file.write(title + '\n')
 else:
 # Nếu tệp tin log đã tồn tại, mở tệp tin và chèn title vào cuối tệp tin
 with open(log_file_path, 'a', encoding='utf-8') as file:
 file.write(title + '\n')
 except Exception as e:
 print(f"Error logging song title: {e}")

async def remove_first_line_from_log():
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 try:
 with open(log_file_path, "r", encoding="utf-8") as f:
 lines = f.readlines()
 # Xóa dòng đầu tiên trong list lines
 lines = lines[1:]
 with open(log_file_path, "w", encoding="utf-8") as f:
 for line in lines:
 f.write(line)
 except Exception as e:
 print(f"Error removing first line from log: {e}")
 
async def clear_log_file():
 log_file_path = "C:\\Bot Music 2\\song_log.txt"
 try:
 with open(log_file_path, "w", encoding="utf-8") as f:
 f.truncate(0)
 except Exception as e:
 print(f"Error clearing log file: {e}")


async def play_next_song(guild_id, queues, voice_client, skip=False):
 queue = queues.get(guild_id, [])
 if queue:
 player = queue.pop(0)
 voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next_song(guild_id, queues, voice_client, skip=False), voice_client.loop))
 if skip:
 return
 else:
 await remove_first_line_from_log() # Xóa dòng đầu tiên trong file log
 elif skip:
 await remove_first_line_from_log() # Xóa dòng đầu tiên trong file log
 await voice_client.disconnect()
 del voice_client[guild_id] # Xóa voice_client sau khi dừng
 else:
 await clear_log_file() # Xóa dòng đầu tiên trong file log
 await voice_client.disconnect()
 del voice_client[guild_id] # Xóa voice_client sau khi dừng



I have tried asking ChatGPT, Gemini, or Bing, and they always lead me into a loop of errors that cannot be resolved. This error only occurs when the song naturally finishes playing due to its duration. If the song is playing and I use the command !skip, the next song in the queue will play and function normally. I noticed that it seems like if a song ends naturally, the song queue is also cleared immediately. I hope someone can help me with this


-
How to write unit tests for your plugin – Introducing the Piwik Platform
17 novembre 2014, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to verify user permissions). This time you’ll learn how to write unit tests in Piwik. For this tutorial you will need to have basic knowledge of PHP, PHPUnit and the Piwik platform.
When is a test a unit test ?
There are many different opinions on this and it can be sometimes hard to decide. At Piwik we consider a test as a unit test if only a single method or class is being tested and if a test does not have a dependency to the filesystem, web, config, database or to any other plugin.
If a test is slow it can be an indicator that it is not a unit test. “Slow” is of course a bit vague. We will cover how to write other type of tests, such as integration tests, in one of our next blog posts.
Getting started
In this post, we assume that you have already installed Piwik 2.9.0 or later via git, set up your development environment and created a plugin. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik and other Guides that help you to develop a plugin.
Let’s create a unit test
We start by using the Piwik Console to create a new unit test :
./console generate:test --testtype unit
The command will ask you to enter the name of the plugin the created test should belong to. I will use the plugin name “Insights”. Next it will ask you for the name of the test. Here you usually enter the name of the class you want to test. I will use “Widgets” in this example. There should now be a file
plugins/Insights/tests/Unit/WidgetsTest.php
which contains already an example to get you started easily :- /**
- * @group Insights
- * @group WidgetsTest
- * @group Plugins
- */
- class WidgetsTest extends \PHPUnit_Framework_TestCase
- {
- public function testSimpleAddition()
- {
- $this->assertEquals(2, 1+1);
- }
- }
We don’t want to cover how you should write your unit test. This is totally up to you. If you have no experience in writing unit tests yet, we recommend to read articles on the topic, or a book, or to watch videos or anything else that will help you learn best.
Running a test
To run a test we will use the command
tests:run
which allows you to execute a test suite, a specific file or a group of tests.To verify whether the created test works we will run it as follows :
./console tests:run WidgetsTest
This will run all tests having the group
WidgetsTest
. As other tests can use the same group you might want to pass the path to your test file instead :./console tests:run plugins/Insights/tests/Unit/Widgets.php
If you want to run all tests within your plugin pass the name of your plugin as an argument :
./console tests:run insights
Of course you can also define multiple arguments :
./console tests:run insights WidgetsTest
This will execute all tests within the insights plugin having the group WidgetsTest. If you only want to run unit tests within your plugin you can do the following :
./console tests:run insights unit
Advanced features
Isn’t it easy to create a unit test ? We never even created a file ! You can accomplish even more if you want : You can generate other type of tests, you can run tests on Amazon’s AWS and more. Unfortunately, not everything is documented yet so we recommend to discover more features by executing the commands
./console list tests
and./console help tests:run
.If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.