fix(youtubedl): use two digits and print at least two segments
This commit is contained in:
parent
d81821bc51
commit
6e43b8a71a
14
youtubedl.py
14
youtubedl.py
@ -1,10 +1,10 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
import constants
|
||||||
import disnake
|
import disnake
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
|
|
||||||
import constants
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
ytdl = yt_dlp.YoutubeDL(constants.YTDL_OPTIONS)
|
ytdl = yt_dlp.YoutubeDL(constants.YTDL_OPTIONS)
|
||||||
@ -71,16 +71,12 @@ class QueuedSong:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def format_duration(self, duration: int) -> str:
|
def format_duration(self, duration: int) -> str:
|
||||||
segments = []
|
|
||||||
hours, duration = divmod(duration, 3600)
|
hours, duration = divmod(duration, 3600)
|
||||||
if hours > 0:
|
|
||||||
segments.append(hours)
|
|
||||||
minutes, duration = divmod(duration, 60)
|
minutes, duration = divmod(duration, 60)
|
||||||
if minutes > 0:
|
segments = [hours, minutes, duration]
|
||||||
segments.append(minutes)
|
if len(segments) == 3 and segments[0] == 0:
|
||||||
if duration > 0:
|
del segments[0]
|
||||||
segments.append(duration)
|
return f"{':'.join(f'{s:0>2}' for s in segments)}"
|
||||||
return f"{':'.join(str(s) for s in segments)}"
|
|
||||||
|
|
||||||
|
|
||||||
def __reload_module__():
|
def __reload_module__():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user