このコミットが含まれているのは:
@@ -7,8 +7,8 @@ import sys
|
||||
import wave
|
||||
from datetime import datetime, timedelta
|
||||
from enum import Enum, auto
|
||||
from typing import Callable, TypedDict
|
||||
from io import BytesIO
|
||||
from typing import Callable, TypedDict
|
||||
|
||||
import cv2
|
||||
import emoji
|
||||
@@ -20,7 +20,6 @@ import pytchat
|
||||
import requests
|
||||
from cv2 import VideoCapture
|
||||
from ephem import Moon, Observer, Sun
|
||||
from pydub import AudioSegment
|
||||
from pygame import Rect, Surface
|
||||
from pygame.font import Font
|
||||
from pygame.mixer import Sound
|
||||
@@ -53,7 +52,6 @@ def main (
|
||||
x = CWindow.WIDTH * 3 / 4,
|
||||
y = CWindow.HEIGHT - 120,
|
||||
balloon = balloon)
|
||||
Video (game, 'snack_time.mp4').play ()
|
||||
CurrentTime (game, SYSTEM_FONT)
|
||||
try:
|
||||
broadcast = Broadcast (os.environ['BROADCAST_CODE'])
|
||||
@@ -752,14 +750,10 @@ class Broadcast:
|
||||
return random.choice (chats)
|
||||
|
||||
|
||||
class NicoVideo (Video):
|
||||
...
|
||||
|
||||
|
||||
class Video (GameObject):
|
||||
fps: int
|
||||
pausing: bool = False
|
||||
sound: Sound
|
||||
sound: Sound | None
|
||||
surfaces: list[Surface]
|
||||
|
||||
def __init__ (
|
||||
@@ -776,9 +770,13 @@ class Video (GameObject):
|
||||
def _create_sound (
|
||||
self,
|
||||
path: str,
|
||||
) -> Sound:
|
||||
) -> Sound | None:
|
||||
bytes_io = BytesIO ()
|
||||
audio = AudioSegment.from_file (path, format = path.split ('.')[-1])
|
||||
try:
|
||||
from pydub import AudioSegment
|
||||
audio = AudioSegment.from_file (path, format = path.split ('.')[-1])
|
||||
except ModuleNotFoundError:
|
||||
return None
|
||||
audio.export (bytes_io, format = 'wav')
|
||||
bytes_io.seek (0)
|
||||
return pygame.mixer.Sound (bytes_io)
|
||||
@@ -843,7 +841,8 @@ class Video (GameObject):
|
||||
) -> None:
|
||||
self.enabled = True
|
||||
self.pausing = False
|
||||
self.sound.play ()
|
||||
if self.sound is not None:
|
||||
self.sound.play ()
|
||||
|
||||
def stop (
|
||||
self,
|
||||
@@ -872,6 +871,10 @@ class Video (GameObject):
|
||||
super ().update ()
|
||||
|
||||
|
||||
class NicoVideo (Video):
|
||||
...
|
||||
|
||||
|
||||
def fetch_bytes_from_url (
|
||||
url: str,
|
||||
) -> bytes | None:
|
||||
|
||||
新しい課題から参照
ユーザをブロックする