reformat
This commit is contained in:
parent
f65dd85c59
commit
41a4961d2b
@ -55,7 +55,11 @@ class Audio(discord.AudioSource):
|
||||
self.attempts = 0
|
||||
|
||||
def _reduced_durations(self) -> dict[str, str]:
|
||||
return {url: duration for url, duration in self._durations.items() if url == self.url}
|
||||
return {
|
||||
url: duration
|
||||
for url, duration in self._durations.items()
|
||||
if url == self.url
|
||||
}
|
||||
|
||||
def set_source_if_necessary(self):
|
||||
if not hasattr(self, "source"):
|
||||
@ -73,7 +77,9 @@ class Audio(discord.AudioSource):
|
||||
|
||||
def set_source(self):
|
||||
self.schedule_duration_update()
|
||||
self.source = FFmpegNormalAudio(self.url, options=self.options, before_options=self.before_options())
|
||||
self.source = FFmpegNormalAudio(
|
||||
self.url, options=self.options, before_options=self.before_options()
|
||||
)
|
||||
|
||||
def set_already_read(self, already_read: int):
|
||||
self.already_read = already_read
|
||||
@ -110,14 +116,11 @@ class Audio(discord.AudioSource):
|
||||
args = []
|
||||
args += [
|
||||
"ffprobe",
|
||||
"-i",
|
||||
url,
|
||||
*("-i", url),
|
||||
"-show_entries",
|
||||
"format=duration",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-of",
|
||||
"default=noprint_wrappers=1:nokey=1",
|
||||
*("-v", "quiet"),
|
||||
*("-of", "default=noprint_wrappers=1:nokey=1"),
|
||||
"-sexagesimal",
|
||||
]
|
||||
ap = await asyncio.create_subprocess_exec(*args, stdout=asyncio.subprocess.PIPE)
|
||||
@ -126,7 +129,9 @@ class Audio(discord.AudioSource):
|
||||
pass
|
||||
else:
|
||||
assert ap.stdout is not None
|
||||
self._durations[url] = (await ap.stdout.read()).decode().strip().split(".")[0]
|
||||
self._durations[url] = (
|
||||
(await ap.stdout.read()).decode().strip().split(".")[0]
|
||||
)
|
||||
|
||||
async def _update_duration(self):
|
||||
async with self._duration_lock:
|
||||
@ -148,9 +153,7 @@ class Audio(discord.AudioSource):
|
||||
def before_options(self) -> str:
|
||||
before_options = ""
|
||||
if "http" in self.url and not self.unstable:
|
||||
before_options += (
|
||||
" -reconnect 1 -reconnect_at_eof 0 -reconnect_streamed 1 -reconnect_delay_max 60 -copy_unknown"
|
||||
)
|
||||
before_options += " -reconnect 1 -reconnect_at_eof 0 -reconnect_streamed 1 -reconnect_delay_max 60 -copy_unknown"
|
||||
if self.already_read:
|
||||
before_options += f" -ss {self.source_seconds()}"
|
||||
return before_options.strip()
|
||||
@ -184,7 +187,9 @@ class Audio(discord.AudioSource):
|
||||
if self.attempts < 5 or random.random() > 0.1:
|
||||
self.attempts += 1
|
||||
self.regenerating = True
|
||||
self.loop.create_task(self.regenerate("underran" if droppable else "not droppable"))
|
||||
self.loop.create_task(
|
||||
self.regenerate("underran" if droppable else "not droppable")
|
||||
)
|
||||
return FILL
|
||||
else:
|
||||
print(f"dropped {self.origin}")
|
||||
@ -224,7 +229,9 @@ class Audio(discord.AudioSource):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
async def respawn(cls, servicing: AServicing, guild: discord.Guild, respawn: dict) -> Audio:
|
||||
async def respawn(
|
||||
cls, servicing: AServicing, guild: discord.Guild, respawn: dict
|
||||
) -> Audio:
|
||||
member_id: int | None = respawn["rby"]
|
||||
if member_id is None:
|
||||
member = None
|
||||
|
Loading…
Reference in New Issue
Block a user