Skip to main content

Medicure

tests codecov pre-commit.ci PyPI Version Python Versions Documentation Status

Medicure is a cosmetic treatment for your media files: movies, TV shows and also their subtitles. Medicure provides a command-line tool and also a Python package for you to properly rename, sort tracks and correct tracks info for your files.

Name

The word medicure is combination of media and the Latin word cura which means "care".

Installation

The easiest way to install is from PyPI:

pip install medicure

Alternatively, you can install directly from GitHub:

pip install git+https://github.com/alirezatheh/medicure.git

Requirements

  • TMDB API Key: Medicure uses TMDB's API to get correct info for movies and TV shows. So you need to create a TMDB account and generate an API key in order to use Medicure.
  • Mediainfo: Medicure requires Mediainfo to extract track info from video and audio files.
  • MKVToolNix: Medicure uses mkvmerge to craete new treated media files. mkvmerge is one of the MKVToolNix's command-line tools.

Simple Example

In this example we want to treat Peaky Blinders's Season 6 video files, downloaded from PSArips.

First we search for the TV show in TMDB to see season names. In this case season name starts with Series. In our TV shows directory we create Peaky Blinders/Series 6 directory and put the files there. Directory structure will look like this:

TV Shows
└── Peaky Blinders
    └── Series 6
        ├── Peaky.Blinders.S06E01.1080p.10bit.WEB-DL.x265.HEVC.PSA.AM.mkv
        ├── Peaky.Blinders.S06E02.INTERNAL.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
        ├── Peaky.Blinders.S06E03.INTERNAL.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
        ├── Peaky.Blinders.S06E04.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
        ├── Peaky.Blinders.S06E05.INTERNAL.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
        └── Peaky.Blinders.S06E06.1080p.10bit.WEB-DL.x265.PSA.AM.mkv

And each file has the following track infos:

Type Title Language Default Forced
Video Undetermined Yes No
Audio English Yes No
Subtitle English Yes No

Now we run the following python snippet:

from pathlib import Path

from medicure import Medicure, DubbingSupplier

medicure = Medicure(
    tmdb_api_key='YOUR_TMDB_API_KEY',
    tvshows_directory=Path('path/to/tvshows_directory'),
)
medicure.treat_media(
    # You can find this in url of TV show in IMDb.
    imdb_id='tt2442560',
    file_search_patterns=[
        # We have only one file for each episode that can be found by
        # this pattern.
        'PSA',
    ],
    video_language_code='eng',
    video_source='PSA',
    video_release_format='WEB-DL',
    dubbing_suppliers=[
        # In this example we only have one dubbing supplier and that's
        # which contains original audio and subtitle.
        DubbingSupplier(
            name='original',
            file_id=0,
            correct_language_code='eng',
            audio_language_code='eng',
            subtitle_language_code='eng',
        ),
    ],
    season_number=6,
)

Then directory structure will look like this:

TV Shows
└── Peaky Blinders
    ├── Series 6
    │   ├── Peaky.Blinders.S06E01.1080p.10bit.WEB-DL.x265.HEVC.PSA.AM.mkv
    │   ├── Peaky.Blinders.S06E02.INTERNAL.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
    │   ├── Peaky.Blinders.S06E03.INTERNAL.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
    │   ├── Peaky.Blinders.S06E04.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
    │   ├── Peaky.Blinders.S06E05.INTERNAL.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
    │   └── Peaky.Blinders.S06E06.1080p.10bit.WEB-DL.x265.PSA.AM.mkv
    └── Series 6 Edited
        ├── Peaky Blinders - S06E01 - Black Day.mkv
        ├── Peaky Blinders - S06E02 - Black Shirt.mkv
        ├── Peaky Blinders - S06E03 - Gold.mkv
        ├── Peaky Blinders - S06E04 - Sapphire.mkv
        ├── Peaky Blinders - S06E05 - The Road to Hell.mkv
        └── Peaky Blinders - S06E06 - Lock and Key.mkv

And each file track infos:

Type Title Language Default Forced
Video PSA WEB-DL English Yes No
Audio English Yes No
Subtitle English No No

Let's treat again, this time using Medicure's command-line interface.

Since we're using CLI for the first time, we need to save our TMDB API key and TV shows directory locally:

medicure save tmdb-info YOUR_TMDB_API_KEY
medicure save collection-info \
--tvshows-directory PATH_TO_YOUR_TVSHOWS_DIRECTORY

Now we can run:

medicure treat media \
tt2442560 \
'["PSA"]' \
eng \
PSA \
WEB-DL \
'[["original", 0, "eng", "eng", "eng"]]' \
6

If you want to learn more about Medicure with more in depth examples you can visit Medicure's documentation.

Metadata

Release files for medicure 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medicure 0.3.0
File Size Uploaded Provenance
medicure-0.3.0.tar.gz 17.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for medicure 0.3.0
File Interpreter ABI Platform
medicure-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.8 kB

Release files / medicure-0.3.0.tar.gz

Download URL medicure-0.3.0.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fd122cf99838f85fc4b107e6b40ec4ba241edf1e450f88b43a15463abad8f3bd
BLAKE2b-256 checksum
How to use checksums
77d2bbc31f00dc8e0c3a2183ec54346df99b3b0c4f33db839b5a1481f2462fa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / medicure-0.3.0-py3-none-any.whl

Download URL medicure-0.3.0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34704ebc3185afbbf31b8ab9c4d5662ea00bff5dba3d8c11a612806ed37e263d
BLAKE2b-256 checksum
How to use checksums
7aba75e00ac748bbc38d0e8f8dc5f6799c52c91d50766fa587b7bb6ddc58afb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Security for medicure 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page