Skip to content

Commit

Permalink
switch to uv for package management
Browse files Browse the repository at this point in the history
  • Loading branch information
fnep committed Jan 9, 2025
1 parent 48a91bf commit de8f20e
Show file tree
Hide file tree
Showing 13 changed files with 1,139 additions and 1,382 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "pip"
schedule:
interval: "monthly"
ignore:
- dependency-type: "security"

- package-ecosystem: "pip"
schedule:
interval: "daily"
commit-message:
prefix: "security"
15 changes: 5 additions & 10 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ on:
tags: [ 'v*.*' ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
# base path to the dockerfile
DOCKERFILE_PATH: .
# build platform
BUILD_PLATFORMS: linux/amd64,linux/arm64

jobs:
Expand All @@ -26,7 +21,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -35,11 +30,11 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -52,9 +47,9 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: ${{ env.DOCKERFILE_PATH }}
context: .
platforms: ${{ env.BUILD_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
32 changes: 9 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,22 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run pytest
run: poetry run pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml
run: uv run pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml

- name: Upload pytest test results
uses: actions/upload-artifact@v3
Expand Down
5 changes: 0 additions & 5 deletions .gitpod.Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions .gitpod.yml

This file was deleted.

10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
FROM python:3.10 AS build
RUN pip3 install poetry poetry-dynamic-versioning
FROM ghcr.io/astral-sh/uv:python3.13-alpine AS build
COPY ./ /app/
RUN rm -rf /app/dist
WORKDIR /app
RUN poetry install
RUN poetry build
RUN apk add git
RUN uv sync --frozen && uv build

FROM python:3.10
FROM python:3.13
COPY --from=build /app/dist/*.whl /tmp/
RUN pip3 install /tmp/*.whl && rm /tmp/*.whl
RUN mkdir /data
Expand Down
1 change: 0 additions & 1 deletion README

This file was deleted.

250 changes: 129 additions & 121 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,121 +1,129 @@
MediathekView Downloader
========================

A command line tool to download videos from public broadcasting services in Germany. It's name is a reference to the `MediathekView project <https://github.com/mediathekview/MediathekView>`_, because they are doing the actual work to provide a database of available shows and download sources (this is just a small helper script). Unfortunately, their client requires Java and its not so easy to automate downloads. This tools aims to make it easier to download your favorite shows to your local or network storage using a cronjob.


Features
--------

- Commandline first interface.
- Powerful filter system for lists and download selection.
- Download .mp4, .flv and .m3u8 (HLS) media inclusive subtitles.
- Keep track of downloaded files and don't download them again.
- Template naming of the downloaded files.


Usage examples
--------------


Searching for shows
~~~~~~~~~~~~~~~~~~~

.. code::
$ mtv_dl list topic='extra 3' duration+20m age-1w
+----------+---------+------------------------+---------+------+---------------------------+----------+---------+--------+---------------------+
| hash | channel | title | topic | size | start | duration | age | region | downloaded |
+----------+---------+------------------------+---------+------+---------------------------+----------+---------+--------+---------------------+
| 49ea2aa7 | ARD | Extra 3 vom 10.08.2017 | extra 3 | 646 | 2017-08-10T22:45:00+02:00 | 43m | 14h 15m | | None |
+----------+---------+------------------------+---------+------+---------------------------+----------+---------+--------+---------------------+
Download all shows matching the filter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code::
$ mtv_dl download topic='extra 3' duration+20m age-1w
Download all shows matching any filter a text file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code::
$ cat shows.txt
channel=ARD topic='extra 3' title!=spezial duration+20m
channel=ZDF topic='Die Anstalt' duration+45m
channel=ZDF topic=heute-show duration+20m
.. code::
$ mtv_dl download --dir=/media --high --target='{dir}/{channel}/[{topic} {date}] {title}{ext}' --sets=shows.txt
Use a config file to apply useful defaults for all commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is my cronjob default.

.. code::
$ cat ~/.mtv_dl.yml
high: true
dir: /media
target: '{dir}/{channel}/[{topic} {date}] {title}{ext}'
.. code::
$ crontab -l
0 * * * * mtv_dl download --logfile=~/download.log --sets=~/shows.txt
Get show details in JSON format
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code::
$ mtv_dl dump hash=49ea2aa7
[
{
"age": "17:15:00",
"channel": "ARD",
"description": "[...]",
"duration": "0:43:00",
"hash": "49ea2aa7",
"new": false,
"region": "",
"size": 646,
"start": "2017-08-10T22:45:00+02:00",
"title": "Extra 3 vom 10.08.2017",
"topic": "extra 3",
"url_http": "[...]",
"url_http_hd": "[...]",
"url_http_small": "[...]",
"url_subtitles": "",
"website": "[...]"
}
]
Installation
------------

Requirements:

- python3.8 or later
- everything in requirements.txt

The easiest way is to install using pip:

.. code:: shell
$ python3 -m pip install mtv-dl
Support
-------

This project is free and open source (MIT licensed). It's not very actively maintained but also not neglected. It's just here in case it's useful for somebody.

Für "Issues": Ich komme aus Dresden und spreche auch Deutsch.
# MediathekView Downloader

A command line tool to download videos from public broadcasting services in Germany. It's name is a reference to the [MediathekView project](https://github.com/mediathekview/MediathekView), because they are doing the actual work to provide a database of available shows and download sources (this is just a small helper script). Unfortunately, their client requires Java and its not so easy to automate downloads. This tools aims to make it easier to download your favorite shows to your local or network storage using a cronjob.


## Features

- Commandline first interface.
- Powerful filter system for lists and download selection.
- Download .mp4, .flv and .m3u8 (HLS) media inclusive subtitles.
- Keep track of downloaded files and don't download them again.
- Template naming of the downloaded files.


## Usage examples


### Searching for shows

```shell
$ mtv_dl list topic='extra 3' duration+20m age-1w
+----------+---------+------------------------+---------+------+---------------------------+----------+---------+--------+---------------------+
| hash | channel | title | topic | size | start | duration | age | region | downloaded |
+----------+---------+------------------------+---------+------+---------------------------+----------+---------+--------+---------------------+
| 49ea2aa7 | ARD | Extra 3 vom 10.08.2017 | extra 3 | 646 | 2017-08-10T22:45:00+02:00 | 43m | 14h 15m | | None |
+----------+---------+------------------------+---------+------+---------------------------+----------+---------+--------+---------------------+
```

### Download all shows matching the filter

```shell
$ mtv_dl download topic='extra 3' duration+20m age-1w
```


### Download all shows matching any filter a text file

```shell
$ cat shows.txt
channel=ARD topic='extra 3' title!=spezial duration+20m
channel=ZDF topic='Die Anstalt' duration+45m
channel=ZDF topic=heute-show duration+20m
```

```shell
$ mtv_dl download --dir=/media --high --target='{dir}/{channel}/[{topic} {date}] {title}{ext}' --sets=shows.txt
```

### Use a config file to apply useful defaults for all commands

This is my cronjob default.

```shell
$ cat ~/.mtv_dl.yml
high: true
dir: /media
target: '{dir}/{channel}/[{topic} {date}] {title}{ext}'
```

```shell
$ crontab -l
0 * * * * mtv_dl download --logfile=~/download.log --sets=~/shows.txt
```


### Get show details in JSON format

```shell
$ mtv_dl dump hash=49ea2aa7
[
{
"age": "17:15:00",
"channel": "ARD",
"description": "[...]",
"duration": "0:43:00",
"hash": "49ea2aa7",
"new": false,
"region": "",
"size": 646,
"start": "2017-08-10T22:45:00+02:00",
"title": "Extra 3 vom 10.08.2017",
"topic": "extra 3",
"url_http": "[...]",
"url_http_hd": "[...]",
"url_http_small": "[...]",
"url_subtitles": "",
"website": "[...]"
}
]
```

## Installation


Requirements:

- python3.10 or later
- everything in pyproject.toml

The easiest way is to install using pip:

```shell
$ python3 -m pip install mtv-dl
```

### Docker

You can use docker to run the latest version.

```shell
$ docker run -v ./my-data/:/data ghcr.io/fnep/mtv_dl
```

### Development


This project uses uv for building, publishing and dependencies.

To get startet checkout the repository and

```shell
$ uv run mtv_dl
```

## Support

This project is free and open source (MIT licensed). It's not very actively maintained but also not neglected. It's just here in case it's useful for somebody.

Für "Issues": Ich komme aus Dresden und spreche auch Deutsch.
Loading

0 comments on commit de8f20e

Please sign in to comment.