Skip to content

Commit

Permalink
Merge pull request #6 from niklasheld/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
niklasheld authored Oct 30, 2022
2 parents 2a21ada + 44ee6fc commit d3ba8ec
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 8 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
name: Build Container
on:
push:
branches: [ master ]
workflow_dispatch:
release:
types: [published]

jobs:
build:
build-container:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2


- name: Docker Metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/niklasheld/zdf-download
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to Registry
uses: docker/login-action@v1
with:
Expand All @@ -23,4 +35,4 @@ jobs:
with:
context: .
push: true
tags: ghcr.io/niklasheld/zdf-download:latest
tags: ${{ steps.metadata.outputs.tags }}
18 changes: 18 additions & 0 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Quality
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarqube:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: Scan SonarQube
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Version
on:
push:
branches:
- master
jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install -g semantic-release
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_DEPLOY_TOKEN }}
8 changes: 8 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
20 changes: 19 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<h1 style="text-alignment: center">ZDF-Download</h1>

[![Build Container](https://github.com/niklasheld/zdf-download/actions/workflows/build-container.yaml/badge.svg)](https://github.com/niklasheld/zdf-download/actions/workflows/build-container.yaml)
[![Build Container](https://github.com/niklasheld/zdf-download/actions/workflows/quality.yaml/badge.svg)](https://github.com/niklasheld/zdf-download/actions/workflows/quality.yaml)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=zdf-download)](https://sonarcloud.io/summary/new_code?id=zdf-download)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=zdf-download&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=zdf-download)
[![Known Vulnerabilities](https://snyk.io/test/github/niklasheld/zdf-download/badge.svg)](https://snyk.io/test/github/niklasheld/zdf-download)

Script to automatically download new episodes of TV shows from the ZDF Mediathek. The script is meant to quickly download *new* episodes, not all available episodes.

Expand All @@ -13,7 +18,7 @@ As an option, you can also define regex-filters on fields from the rss-feed to f

## Application logic

- Script assumes that all files in the target folder are named `Showname SxxExx` naming-scheme and no files violate this scheme
- Script assumes that all files in the target folder are named `<Showname> SxxExx` naming-scheme and no files violate this scheme. It also asumes that you are using a flat filestructure for all seasons.
- When a new episode is found, a sequential filename is generated for the new download. If you want the file to be downloaded in a new season, you have to rename it manually. The next file will then be sequentially added to this season.
- After a file is downloaded, it's URL is added to a history-file and it will not be downloaded again.

Expand All @@ -22,6 +27,19 @@ As an option, you can also define regex-filters on fields from the rss-feed to f

Before starting the script, add a custom `configuration.yaml`-file to your directory. You can find an example configuration in the configuration-folder

### Full Configuration

See `configuration-example.yaml` for an example configuration. The configuration file has to be placed at `/app/configuration/configuration.yaml`.

| Paramter | Description | Example |
| --- | --- | --- |
| interval | Minutes between each scan for new episodes | `60` |
| shows[].feed-url | URL to the RSS-feed for the show you want to download | `"https://www.zdf.de/rss/zdf/comedy/zdf-magazin-royale"` |
| shows[].filter.regex | Regular expression to match only specific episodes of a show | `"zdf-magazin-royale-vom-\\d"` |
| shows[].filter.regexField | Field in the RSS-feed that is filtered for the regular expression | `"link"` |
| shows[].filter.minDate | Minimum date of episode to download | `"2021-09-01 00:00+00:00"` |
| shows[].download.folder | Path to the folder where the downloaded files are located for this show | `"/serien/ZDF Magazin Royale"` |
| shows[].download.filename | Base filename that is used to consecutively name episodes. | `"ZDF Magazin Royale"` |
### Docker

The recommended way to use this program is to start a lightweight Docker-container and mount your media-folders and configuration.
Expand Down
3 changes: 3 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sonar.organization=niklasheld
sonar.projectKey=zdf-download
sonar.sources=.
2 changes: 1 addition & 1 deletion zdf_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def find_filename(self, download: DownloadConfiguration) -> str:
"""Generate a new filename by adding one to the current newest filename."""
episode_files: List[str] = list(filter(lambda filename: download.filename in filename, sorted(os.listdir(download.folder))))

if not len(episode_files) == 0:
if len(episode_files) > 0:
newest_filename = os.path.splitext(episode_files[-1])[0]
regex = re.match(r"^(.* S\d+E)(\d+)", newest_filename)
filename_base: str = regex.group(1)
Expand Down

0 comments on commit d3ba8ec

Please sign in to comment.