Skip to content

Commit

Permalink
Merge pull request #4 from XXXFQ:develop
Browse files Browse the repository at this point in the history
Load .env file and improve error handling for station list
  • Loading branch information
XXXFQ authored Nov 20, 2024
2 parents 508730b + eba2152 commit 8c689f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions radiko_recorder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

# 必須引数のチェック
Expand Down
7 changes: 4 additions & 3 deletions radiko_recorder/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
RADIKO_AREA_ID = os.getenv('RADIKO_AREA_ID', 'JP13') # デフォルト値として東京エリア(JP13)を指定
6 changes: 3 additions & 3 deletions test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -45,7 +45,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down

0 comments on commit 8c689f4

Please sign in to comment.