From 13e01c36f1fc8c9d57d68f8e64f6f701c62d01cb Mon Sep 17 00:00:00 2001 From: ARM0930 <72128692+XXXFQ@users.noreply.github.com> Date: Thu, 21 Nov 2024 04:26:47 +0900 Subject: [PATCH 1/2] fix: Load .env file from the current script directory and set default RADIKO_AREA_ID --- radiko_recorder/config.py | 7 ++++--- test.ipynb | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/radiko_recorder/config.py b/radiko_recorder/config.py index cbc7d62..d9827cc 100644 --- a/radiko_recorder/config.py +++ b/radiko_recorder/config.py @@ -2,7 +2,8 @@ from dotenv import load_dotenv -# 環境変数へ反映 -load_dotenv() +# 現在のスクリプトのディレクトリから.envをロード +dotenv_path = os.path.join(os.path.dirname(__file__), '.env') +load_dotenv(dotenv_path) -RADIKO_AREA_ID = os.getenv('RADIKO_AREA_ID') \ No newline at end of file +RADIKO_AREA_ID = os.getenv('RADIKO_AREA_ID', 'JP13') # デフォルト値として東京エリア(JP13)を指定 \ No newline at end of file diff --git a/test.ipynb b/test.ipynb index 4159667..f8df9a3 100644 --- a/test.ipynb +++ b/test.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -45,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [ { From eba21529de5fb0e5ac0af0c1ad23c3c4728db727 Mon Sep 17 00:00:00 2001 From: ARM0930 <72128692+XXXFQ@users.noreply.github.com> Date: Thu, 21 Nov 2024 04:51:57 +0900 Subject: [PATCH 2/2] fix: Add error handling for displaying station list --- radiko_recorder/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/radiko_recorder/__init__.py b/radiko_recorder/__init__.py index a8cbed6..9572f32 100644 --- a/radiko_recorder/__init__.py +++ b/radiko_recorder/__init__.py @@ -123,8 +123,11 @@ def main(argv=None): args = parser.parse_args(argv) if args.station_list: - # 放送局リストを表示 - _show_station_list(args.area_id) + try: + # 放送局リストを表示 + _show_station_list(args.area_id) + except ValueError as e: + print(e) return # 必須引数のチェック