# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           python 1.0

name                beets
version             1.6.0
revision            2

categories          audio
platforms           {darwin any}
supported_archs     noarch
license             MIT

description         music library manager and MusicBrainz tagger
long_description    Beets is the media library management system for obsessive music geeks. \
                    The purpose of beets is to get your music collection right once and for all. \
                    It catalogs your collection, automatically improving its metadata as it goes. \
                    It then provides a bouquet of tools for manipulating and accessing your music.

homepage            https://beets.io/

maintainers         nomaintainer

checksums           rmd160  5866c23b2fcd122f4044601fe6b2631107f028f0 \
                    sha256  aa6fb734e44afc9b039c0abd0edd4c7706df00d4eb4aae7afa9ff4b6bb15525d \
                    size    1698333

python.default_version 310

depends_build-append \
                    port:py${python.version}-setuptools

if {$subport eq $name} {
    conflicts       ${name}-devel
}

subport ${name}-devel {
    conflicts       $name

    github.setup    beetbox beets bcf180d14dd14604e1d82414fac28d41c275e1c9
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20231217
    revision        0

    checksums       rmd160  a28f33f2da8521e7f2c854019ce1deeed3e3a990 \
                    sha256  6d38be22f6be03edf8fd9feb97d77b0dab78dd179f1af762bb669dafac7cf77a \
                    size    2239737

    depends_build-append \
                    port:py${python.version}-sphinx

    depends_lib-append \
                    port:py${python.version}-typing_extensions

    post-build {
        system -W ${worksrcpath} "make -C docs SPHINXBUILD=${python.prefix}/bin/sphinx-build BUILDDIR=../ man"
    }
}

if {${name} eq ${subport} || "${name}-devel" eq ${subport}} {
    depends_lib-append \
                    port:py${python.version}-py7zr \
                    port:py${python.version}-Pillow \
                    port:py${python.version}-acoustid \
                    port:py${python.version}-beautifulsoup4 \
                    port:py${python.version}-confuse \
                    port:py${python.version}-discogs-client \
                    port:py${python.version}-flask \
                    port:py${python.version}-flask-cors \
                    port:py${python.version}-jellyfish \
                    port:py${python.version}-langdetect \
                    port:py${python.version}-last \
                    port:py${python.version}-mediafile \
                    port:py${python.version}-mpd2 \
                    port:py${python.version}-munkres \
                    port:py${python.version}-musicbrainzngs \
                    port:py${python.version}-mutagen \
                    port:py${python.version}-rarfile \
                    port:py${python.version}-reflink \
                    port:py${python.version}-requests \
                    port:py${python.version}-requests-oauthlib \
                    port:py${python.version}-soco \
                    port:py${python.version}-unidecode \
                    port:py${python.version}-pyxdg \
                    port:py${python.version}-yaml

    # ffmpeg-devel now tracks ffmpeg7,
    # so no path-style for ffmpeg v. 4.x.
    depends_run-append \
                    port:chromaprint \
                    port:ImageMagick \
                    port:ffmpeg \
                    port:flac \
                    port:mp3val

    # Do not pull in Go on PowerPC
    if {${os.arch} ne "powerpc"} {
        depends_run-append \
                    port:ipfs
    }

    depends_test-append \
                    port:py${python.version}-coverage \
                    port:py${python.version}-flask \
                    port:py${python.version}-mock \
                    port:py${python.version}-pytest \
                    port:py${python.version}-responses

    post-destroot {
        xinstall -d ${destroot}${prefix}/share/man/man1
        xinstall -m 0644 {*}[glob ${worksrcpath}/man/*.1] ${destroot}${prefix}/share/man/man1/

        xinstall -d ${destroot}${prefix}/share/man/man5
        xinstall -m 0644 {*}[glob ${worksrcpath}/man/*.5] ${destroot}${prefix}/share/man/man5/

        xinstall -d ${destroot}${prefix}/share/${name}
        xinstall -m 0644 -W ${worksrcpath} README.rst LICENSE ${destroot}${prefix}/share/${name}
    }

    test.run        yes
    test.cmd        py.test-${python.branch}
    test.env        PYTHONPATH=${worksrcpath}/build/lib
} elseif {${name} ne "${name}-full"} {
    python.rootname ${subport}

    depends_lib-append \
                    bin:beet:beets

    post-destroot {
        foreach f {__init__.py __init__.pyc __init__.pyo __pycache__} {
            set fp "${destroot}${python.pkgd}/beetsplug/$f"
            if {[file exists ${fp}]} {
                file delete -force ${fp}
            }
        }
    }
}

subport ${name}-alternatives {
    version         0.11.0
    revision        0

    license         MIT

    description     beets plugin to manage multiple files
    long_description \
                    {*}${description}

    distfiles       [string map {- _} ${subport}]-${version}${extract.suffix}

    homepage        https://www.github.com/geigerzaehler/beets-alternatives

    checksums       rmd160  e9d5d9f79b4b677849764b66f78eb00615ffb53a \
                    sha256  b9380301cf728864442038e1aeed5324645c7223a4b77711fd3ddbdd62c1900d \
                    size    13757

    extract.rename  yes

    python.pep517   yes
    python.pep517_backend \
                    poetry
}

subport ${name}-amazon {
    github.setup    jmwatte beet-amazon da25d7671f3814a8401b004f592ccf0633197edf
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20210908
    revision        1

    # See: https://github.com/jmwatte/beet-amazon/issues/7
    license         MIT

    description     plugin for beets that lets you search amazon for album-details
    long_description \
                    {*}${description}

    checksums       rmd160  144a3a4935fa56b30266f6b8233850d2836da406 \
                    sha256  a6dc5061c9354b8e6fa77a42f7568f07e01ef8011a267547f291aa3a0f7098ca \
                    size    3532

    depends_lib-append \
                    port:py${python.version}-bottlenose

    build {}

    destroot {
        xinstall -d ${destroot}${prefix}/share/${subport}
        xinstall -m 0644 ${worksrcpath}/README.md ${destroot}${prefix}/share/${subport}

        xinstall -d ${destroot}${python.pkgd}/beetsplug
        xinstall -m 0644 ${worksrcpath}/amazon.py ${destroot}${python.pkgd}/beetsplug
    }
}

subport ${name}-artistcountry {
    version         0.3.0
    revision        1

    license         MIT

    description     Beets plugin to retrieve the country of an artist from musicbrainz
    long_description \
                    {*}${description}

    homepage        https://github.com/agrausem/beets-artistcountry

    checksums       rmd160  289bd9b7d0f0f11fcda8194bff5c737e25bcdbcc \
                    sha256  76f18ed29837be1fdd6f661261f290e691b341ce11375a0ae770353af7e04b89 \
                    size    2107
}

subport ${name}-autofix {
    version         0.1.3
    revision        0

    license         MIT

    description     A beets plugin to execute repetitive tasks in one go.
    long_description \
                    {*}${description}

    homepage        https://github.com/adamjakab/BeetsPluginAutofix

    checksums       rmd160  0c152e09d42c82c8f34ee2024afa93b3f83756a3 \
                    sha256  be3ad7230f91ef9f384d0a0b69220d9d4e25e655981387e69f194340a860f768 \
                    size    10986

    depends_lib-append \
                    port:py${python.version}-alive-progress
}

subport ${name}-barcode {
    github.setup    8h2a beets-barcode ad18cace04873157a96c34a48e714874825db724
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20210908
    revision        1

    license         MIT

    description     A plugin for beets that finds releases (on musicbrainz) based on a barcode that is provided via text or decoded from image files
    long_description \
                    {*}${description}

    checksums       rmd160  a866d52c0b4458f5815eb57010ee12737c3c8a94 \
                    sha256  2ec3897a6fb05e2e528b4f154a3eaadde2ab0e758040f1c4566f4fc2a3c4d228 \
                    size    4742

    depends_lib-append \
                    port:py${python.version}-zbar
}

subport ${name}-beetcamp {
    python.rootname beetcamp
    version         0.17.2
    revision        0

    license         GPL-2

    description     Bandcamp autotagger source for beets.
    long_description \
                    {*}${description}

    homepage        https://github.com/snejus/beetcamp

    checksums       rmd160  866ab8fe35e222115bded1c2a2cbcc7d3ab3cb6f \
                    sha256  0b4f75323c43e4b32a6fa2d1ea4e1d9265e0299abd19eb558793f77fd5556bd1 \
                    size    43387

    python.pep517   yes
    python.pep517_backend \
                    poetry

    depends_lib-append \
                    port:py${python.version}-cached-property \
                    port:py${python.version}-country \
                    port:py${python.version}-dateutil \
                    port:py${python.version}-ordered-set \
                    port:py${python.version}-requests

    post-destroot {
        set docdir ${destroot}${prefix}/share/doc/${subport}
        set doc_list [list LICENSE README.md]
        xinstall -d ${docdir}
        foreach f ${doc_list} {
            xinstall -m 644 -W ${worksrcpath} ${f} ${docdir}
            file delete -force ${destroot}/${python.pkgd}/${f}
        }
    }
}

subport ${name}-bpmanalyser {
    version         1.3.3
    revision        1

    license         MIT

    description     A beets plugin for analysing tempo of songs and storing it in the bpm tag.
    long_description \
                    {*}${description}

    homepage        https://github.com/adamjakab/BeetsPluginBpmAnalyser

    checksums       rmd160  4d5371f92997132ab51796f8b3c6469febb02c65 \
                    sha256  c5e5ce8e7919655d42b9b3e60288c51fd921d4b055da4e012400e37bc11fecf4 \
                    size    6684

    depends_lib-append \
                    port:py${python.version}-aubio \
                    port:py${python.version}-numpy
}

subport ${name}-check {
    version         0.13.0
    revision        1

    license         MIT

    description     beets plugin verifying file integrity with checksums
    long_description \
                    {*}${description}

    homepage        https://www.github.com/geigerzaehler/beets-check

    checksums       rmd160  51faf5466651b51e336804004b216e3ee3eac1ce \
                    sha256  ada6bc23b02041a9afa24a4943413950bcd43670d6e5c3f9f8813e5dbbc9bffc \
                    size    13455
}

subport ${name}-copyartifacts {
    python.rootname beets-copyartifacts3
    version         0.1.5
    revision        0

    license         MIT

    description     beets plugin to copy non-music files to import path
    long_description \
                    {*}${description}

    homepage        https://github.com/adammillerio/beets-copyartifacts

    checksums       rmd160  980c23e39688dad1a6396cdc89d6519f10aa73e5 \
                    sha256  522996017cd922f920d1c30963531d493e122c5366ad08f254f3245ea7489028 \
                    size    5814
}

subport ${name}-describe {
    version         0.0.4
    revision        0

    license         MIT

    description     A beets plugin that describes attributes in depth
    long_description \
                    {*}${description}

    homepage        https://github.com/adamjakab/BeetsPluginDescribe

    checksums       rmd160  e444ad447c746ecfa910b5cd96a239eca1e91536 \
                    sha256  2c081460567510c5eb4cb037778053ea688d0e65e49aa29d9f441975b94eaba6 \
                    size    8386

    depends_lib-append \
                    port:py${python.version}-numpy \
                    port:py${python.version}-pandas \
                    port:py${python.version}-termplotlib \
                    port:py${python.version}-termtables
}

subport ${name}-follow {
    github.setup    nolsto beets-follow eb504a0b3b457993d599530a66a54b11b740ecb5
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20210908
    revision        1

    license         MIT

    description     Plugin for the music library manager Beets. Follow artists from your library using muspy.com
    long_description \
                    {*}${description}

    checksums       rmd160  ebe6866b1055ea5459fa33c77b08f904dece5be8 \
                    sha256  e1dd35c3ea1cf8c3f5893fa3b49f3fd2f1c1c230e05f5fa0bf03b805a9eea39a \
                    size    4145

    patch.pre_args-replace  -p0 -p1
    patchfiles      follow-confuse.diff

    depends_lib-append \
                    port:py${python.version}-confuse
}

subport ${name}-goingrunning {
    version         1.2.5
    revision        0

    license         MIT

    description     A beets plugin for creating and exporting songs that match your running session.
    long_description \
                    {*}${description}

    homepage        https://github.com/adamjakab/BeetsPluginGoingRunning

    checksums       rmd160  b38b7afc30937c25c3c397d2c9e7c6ff23d23280 \
                    sha256  e6dd2dec136f666395ad2ca2749a09f374788702c2c773e8a7d7582c99be1887 \
                    size    22366

    depends_lib-append \
                    port:py${python.version}-alive-progress
}

subport ${name}-ibroadcast {
    version         0.5.2
    revision        1

    # beets-ibroadcast is licensed under The Unlicense
    license         public-domain

    description     iBroadcast plugin for Beets
    long_description \
                    {*}${description}

    homepage        https://github.com/ctrueden/beets-ibroadcast

    checksums       rmd160  5411f68f7c2154da9a208fa4935e6a50ba31d457 \
                    sha256  adc3b668305256298b6960d2db6756ad8fc0134f4a4a0ffedfee03a61d5518d4 \
                    size    11363

    depends_lib-append \
                    port:py${python.version}-ibroadcast
}

subport ${name}-importreplace {
    github.setup    edgars-supe beets-importreplace 0.2 v
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    revision        1

    license         MIT

    description     Plugin for beets to perform regex replacements during import
    long_description \
                    {*}${description}

    checksums       rmd160  7a396c53b82be492a98e79bde02d4d0f59e969a8 \
                    sha256  2c63a3c6be7ad7e9bbdb082bd15c460d9b54c29371e05a5bcaae1d31e325f973 \
                    size    4934
}

subport ${name}-mosaic {
    python.rootname beets_mosaic
    version         0.9.1
    revision        1

    license         MIT

    description     Plugin for the music library manager Beets. The mosaic plugin generates a montage of a mosiac from cover art.
    long_description \
                    {*}${description}

    homepage        https://github.com/susannamaria/beets-mosaic

    checksums       rmd160  71d68c17894f255fcea01d6da07782e8eab9b324 \
                    sha256  7e6ff14be69502c394dfc7abe57f144747adba700a2a50dd36c06e9a3e18a966 \
                    size    6195

    depends_lib-append \
                    port:py${python.version}-fonttools \
                    port:py${python.version}-parse \
                    port:py${python.version}-pillow \
                    port:py${python.version}-requests \
                    port:py${python.version}-ttfquery
}

subport ${name}-moveall {
    github.setup    dsedivec beets-plugins c67038d91bca79d9fd52ab316ad9150c1ba1a236
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20210908
    revision        1

    license         MIT

    description     A beet plugin that move all files into beets library
    long_description \
                    {*}${description}

    checksums       rmd160  c93492b8b1b4df2f864acd9467c063cb6640694c \
                    sha256  e055b07c5f5072cacb5c8858b009918b7542fa968964b4133bfc821ccc6f8a9d \
                    size    8110

    patch.pre_args-replace  -p0 -p1
    patchfiles      moveall-2to3.diff

    build {}

    destroot {
        xinstall -d ${destroot}${prefix}/share/${subport}
        xinstall -m 0644 ${worksrcpath}/README.md ${destroot}${prefix}/share/${subport}

        xinstall -d ${destroot}${python.pkgd}/beetsplug
        xinstall -m 0644 ${worksrcpath}/beetsplug/moveall.py ${destroot}${python.pkgd}/beetsplug
    }
}

subport ${name}-noimport {
    version         0.1.0b5
    revision        1

    license         MIT

    description     Beets plugin to add directories to the incremental import 'do not import' list
    long_description \
                    {*}${description}

    homepage        https://www.github.com/ttsda/beets-noimport

    checksums       rmd160  2755bf7b969712da0931c5972ddf23f6aff7ec90 \
                    sha256  86a6291e1de90b292829e6f7286b057be2bc556f5a49e9c30ffead2985ae998a \
                    size    3167
}

subport ${name}-originquery {
    github.setup    x1ppy beets-originquery c353e2b68804cb4dabca0f0f177cee1137888ca4
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20220311
    revision        0

    license         Unknown

    description     Plugin for beets that improves album matching
    long_description \
                    {*}${description}

    checksums       rmd160  cc26fbcc9981a9a5a8f5ca268812f26a9f43c480 \
                    sha256  73811c982fedbef23ad005ec002b8b100a575c7a4667911c64a48380226ecb4a \
                    size    7573

    depends_lib-append \
                    port:py${python.version}-confuse \
                    port:py${python.version}-jsonpath-rw \
                    port:py${python.version}-yaml
}

subport ${name}-summarize {
    github.setup    steven-murray beet-summarize 0d7890097fecf0be4202c972cee8ce9e0b1b8dfb
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20231219
    revision        0

    license         LGPL-3

    description     Summarize beet library statistics
    long_description \
                    {*}${description}

    checksums       rmd160  e1d28adcf278b5754ebec6b06e31710697926365 \
                    sha256  35a5199821d7708c5bba325731a63dbd5223ab8922881659814298de643c838b \
                    size    13330

    depends_build-append \
                    port:py${python.version}-setuptools_scm

    build.env-append \
                    SETUPTOOLS_SCM_PRETEND_VERSION=${version}

    github.livecheck.branch main
}

subport ${name}-usertag {
    github.setup    igordertigor beets-usertag 1b78e48ea471ced50d1e499085d6ef3b935537f1
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20211129
    revision        0

    license         MIT

    description     user defined keyword tags for beets
    long_description \
                    {*}${description}

    checksums       rmd160  30ab572c6400feffaf245da349bf66a63ae39441 \
                    sha256  d486e241309948b5b764c7776a7da2dcebe2dd7ffb36affdf880b77da77d67df \
                    size    2655
}

subport ${name}-xtractor {
    version         0.4.1
    revision        0

    license         MIT

    description     A beets plugin that extracts music descriptors from your audio files
    long_description \
                    {*}${description}

    homepage        https://github.com/adamjakab/BeetsPluginXtractor

    checksums       rmd160  5c085e85faa0e350c84d4861e6b2e5f881819ed5 \
                    sha256  a08c3fc0c6e7911341d57b6a1e2c47eecb353eb2177a562ded10aa6d908626e0 \
                    size    11437

    depends_lib-append \
                    port:py${python.version}-yaml
}

subport ${name}-yearfixer {
    version         0.0.4
    revision        0

    license         MIT

    description     A beets plugin that attempts to fix all missing original_year and year fields
    long_description \
                    {*}${description}

    homepage        https://github.com/adamjakab/BeetsPluginYearFixer

    checksums       rmd160  05913bcd3921d26dff88269b1190fef6f5cf004c \
                    sha256  6b70658cde22c8c5c58fa182f9c50d9cb0ab7e5877e2d5e873058d0369548ff4 \
                    size    6534

    depends_lib-append \
                    port:py${python.version}-requests
}

subport ${name}-full {
    revision        0

    description     Install beets with all plugins.
    long_description \
                    {*}${description}

    distfiles

    depends_lib
    depends_build

    depends_run-append \
                    port:beets-alternatives \
                    port:beets-amazon \
                    port:beets-artistcountry \
                    port:beets-autofix \
                    port:beets-barcode \
                    port:beets-beetcamp \
                    port:beets-bpmanalyser \
                    port:beets-check \
                    port:beets-copyartifacts \
                    port:beets-describe \
                    port:beets-follow \
                    port:beets-goingrunning \
                    port:beets-ibroadcast \
                    port:beets-importreplace \
                    port:beets-mosaic \
                    port:beets-moveall \
                    port:beets-noimport \
                    port:beets-originquery \
                    port:beets-summarize \
                    port:beets-usertag \
                    port:beets-xtractor \
                    port:beets-yearfixer

    build           {}

    destroot        {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 ${filespath}/README ${destroot}${docdir}
    }

    livecheck.type  none
}