Skip to content

Commit

Permalink
軽微な修正 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
sitting-cat authored Nov 19, 2023
1 parent b724ff5 commit ddd4833
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ NUCOSen Broadcastが読み取る環境変数の一覧は次の通りです。
| MAIN_VOLUME | (省略可)省略しない場合は0.3などの0以上1以下の数値を指定すること。指定すると、メインに設定されている配信の音量を設定された値に上書きする。省略した場合は0.5。 |
| SUB_VOLUME | (省略可)省略しない場合は0.3などの0以上1以下の数値を指定すること。指定すると、サブに設定されている配信の音量を設定された値に上書きする。省略しない場合は0.5。 |
| SUB_SOUND_ONLY | (省略可)省略しない場合は1を指定すること。指定すると、サブ画面は映像なし(音楽のみ)で配信に乗るようになる。省略した場合はサブ画面が配信画面右下の枠付きで表示される。 |
| DURATION_OVERWRITE | (使用非推奨) |
Binary file modified requirements.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion src/nucosen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

__version__ = "5.1.1alpha"
__version__ = "5.1.1b2"
2 changes: 1 addition & 1 deletion src/nucosen/discordHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
super().__init__()
config = AutoConfig(search_path=getcwd())
self.url: str = str(
config("LOGGING_DISCORD_WEBHOOK", "BAD_URL")
config("LOGGING_DISCORD_WEBHOOK", default="BAD_URL")
)
if self.url == "BAD_URL":
raise Exception(
Expand Down
19 changes: 12 additions & 7 deletions src/nucosen/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def generateLiveDict(category: str, communityId: str, tags: List[str]):
tagDicts = []
for tag in tags:
tagDicts.append({"label": tag, "isLocked": True})
# TODO - Trueではなく"true"とするべき?
# quote.py isSoundOnlyは"true"でないと機能しない
return {
"title": "{0}".format(category),
# NOTE - For users who will modify this text:
Expand All @@ -110,7 +112,7 @@ def generateLiveDict(category: str, communityId: str, tags: List[str]):
"NUCOSEN_LIVE_DESCRIPTION",
default='<font size="+1">NUCOSenへようこそ!</font>'
)) +
'<br /><br />========== Powered by NUCOSen ==========<br />' +
'<br /><br />========== Powered by NUCOSen ==========' +
'<br />この生放送はBotにより自動的に配信されています。<br />' +
'配信システムのソースコードは ' +
'https://github.com/nucosen/broadcast' +
Expand All @@ -123,9 +125,11 @@ def generateLiveDict(category: str, communityId: str, tags: List[str]):
"isTagOwnerLock": True,
"isMemberOnly": False,
"isTimeshiftEnabled":
False if not config("NUCOSEN_TIMESHIFT_ENABLED", default=False) else True,
False if not config("NUCOSEN_TIMESHIFT_ENABLED",
default=False) else True,
"isUadEnabled":
True if not config("NUCOSEN_USER_AD_DISABLED", default=False) else False,
True if not config("NUCOSEN_USER_AD_DISABLED",
default=False) else False,
"isAutoCommentFilterEnabled": False,
"maxQuality": "1Mbps450p",
"rightsItems": [],
Expand All @@ -145,17 +149,18 @@ def takeReservation(liveDict: Dict[Any, Any], startTime: datetime, duration: int
payload["reservationBeginTime"] = startTime.strftime("%Y-%m-%dT%H:%M:%SZ")
payload["durationMinutes"] = duration
response = post(url=url, headers=header, json=payload)
responseJson: dict = response.json()
responseMeta: dict = responseJson.get("meta", {})

if response.status_code == 401:
session.login()
raise ReLoggedIn("L03 ログインセッション更新")
if response.status_code == 400:
# TODO メンテ以外の400リクエストを除外
if response.status_code == 400 \
and responseMeta.get("errorCode", "") == "OVERLAP_MAINTENANCE":
return response
if response.status_code > 399:
getLogger(__name__).info("枠予約失敗 : {0}".format(response.text))
response.raise_for_status()

return response


Expand Down Expand Up @@ -224,7 +229,7 @@ def reserveLiveToGetOverMaintenance(liveDict: Dict[Any, Any], defaultStartTime:
def reserveLive(title: str, communityId: str, tags: List[str], session: Session) -> None:
liveDict = generateLiveDict(title, communityId, tags)
startTime = getStartTimeOfNextLive()
duration = 360
duration: int = config("DURATION_OVERWRITE", default=360, cast=int)

response = takeReservation(liveDict, startTime, duration, session)
responseJson: dict = response.json()
Expand Down
4 changes: 2 additions & 2 deletions src/nucosen/nucosen.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def config(key): return str(configLoader(key, default=""))
if datetime.now(timezone.utc) + videoInfo[1] > currentLiveEnd - timedelta(minutes=1):
logger.info("引用アボート: 時間内に引用が終了しない見込みです")
database.priorityEnqueue(nextVideoId)
quote.loop(currentLiveId, config(
"CLOSING_VIDEO_ID"), session)
quote.loop(
currentLiveId, SPECIFIC_VIDEO_IDS[CLOSING], session)
live.showMessage(
currentLiveId,
config("NUCOSEN_CLOSING_MESSAGE") or
Expand Down
3 changes: 1 addition & 2 deletions src/nucosen/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ class RetryRequired(Exception):
"sub": {
"source": sourceList[1],
"volume": float(config("SUB_VOLUME", default=0.5)),
"isSoundOnly": bool(config("SUB_SOUND_ONLY", default=False))
"isSoundOnly": str(bool(config("SUB_SOUND_ONLY", default=False))).lower()
}
}


@retry(NetworkErrors, tries=10, delay=1, backoff=2, logger=getLogger(__name__ + ".getCurrent"))
def getCurrent(liveId: str, session: Session) -> Optional[str]:
url = "https://lapi.spi.nicovideo.jp/v1/tools/live/contents/{0}/quotation"
Expand Down

0 comments on commit ddd4833

Please sign in to comment.