Skip to content

Commit

Permalink
Rearange the configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki authored May 27, 2020
1 parent ece465d commit 967cf6b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ dmypy.json
.vscode/

# configuration file
config.json
*.json
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The script accept following command line arguments:

Provide a configuration file. Place the `.podcast_downloader_config.json` it your home directory ([JSON](https://en.wikipedia.org/wiki/JSON) format). It should contain an array of settings. Each setting per RSS channel.

### Podcasts

`Podcasts` is the part of configuration file where you provide the array of objects with fallowing content:

| Property | Type | Required | Default | Note |
|:---------------|:-------:|:--------:|:-------:|:-----|
| `name` | string | yes | - | The name of channel (used in logger) |
Expand All @@ -23,16 +27,18 @@ Provide a configuration file. Place the `.podcast_downloader_config.json` it you
| `require_date` | boolean | no | `false` | Is date of podcast should be added into name of file |
| `disable` | boolean | no | `false` | This podcast will be ignored |

### Example
An example:

```json
[
{
"name": "The Skeptic Guide",
"rss_link": "http://www.theskepticsguide.org/feed/rss.aspx",
"path": "~/podcasts/SGTTU"
}
]
{
"podcasts": [
{
"name": "The Skeptic Guide",
"rss_link": "http://www.theskepticsguide.org/feed/rss.aspx",
"path": "~/podcasts/SGTTU"
}
]
}
```

## In action
Expand Down
6 changes: 3 additions & 3 deletions podcast_downloader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def download_rss_entity_to_path(path, rss_entity: RSSEntity):

CONFIG_FILE = '~/.podcast_downloader_config.json'
log('Loading configuration (from file: "{}")', CONFIG_FILE)
CONFIG = load_configuration_file(os.path.expanduser(CONFIG_FILE))

CONFIGURATION = load_configuration_file(os.path.expanduser(CONFIG_FILE))
RSS_SOURCES = CONFIGURATION['podcasts']
DOWNLOADS_LIMITS = int(sys.argv[2]) \
if len(sys.argv) > 2 and sys.argv[1] == '--downloads_limit' and sys.argv[2].isalnum() \
else sys.maxsize

for rss_source in CONFIG:
for rss_source in RSS_SOURCES:
rss_source_name = rss_source['name']
rss_source_path = rss_source['path']
rss_source_link = rss_source['rss_link']
Expand Down

0 comments on commit 967cf6b

Please sign in to comment.