# -*- 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
conflicts           beets-devel
version             2.3.1
revision            0

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  31abc456c5b664a7536d5616924d066aae06f6e9 \
                    sha256  87598721a14af89a06d5ad3d9e8138f8ac112510271a981a90b840ed784d5712 \
                    size    2133246

python.default_version 313
python.pep517_backend poetry

subport ${name}-devel {
    conflicts       $name

    github.setup    beetbox beets 268075063fbf5f796ee1bc419e5268f593c85f4d
    github.tarball_from archive
    version         20250729
    revision        0

    checksums       rmd160  6681ca76205f8e04c864b53d83af1af0e3aa7647 \
                    sha256  b57cf0d2ae432c7527c202b9f88cf657365465fa13c4622dd05ef988ad88aa0e \
                    size    2303429

    ## Building the documentation currently fails... skip for now
    ## depends_build-append \
    ##                 port:py${python.version}-sphinx

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

if {${name} eq ${subport} || "${name}-devel" eq ${subport}} {
    # required dependencies
    depends_lib-append \
                    port:py${python.version}-confuse \
                    port:py${python.version}-jellyfish \
                    port:py${python.version}-lap \
                    port:py${python.version}-mediafile \
                    port:py${python.version}-musicbrainzngs \
                    port:py${python.version}-numpy \
                    port:py${python.version}-platformdirs \
                    port:py${python.version}-yaml \
                    port:py${python.version}-unidecode

    # optional dependencies
    depends_lib-append \
                    port:py${python.version}-beautifulsoup4 \
                    port:dbus-python${python.version} \
                    port:py${python.version}-flask \
                    port:py${python.version}-flask-cors \
                    port:py${python.version}-langdetect \
                    port:py${python.version}-librosa \
                    port:py${python.version}-mutagen \
                    port:py${python.version}-Pillow \
                    port:py${python.version}-py7zr \
                    port:py${python.version}-acoustid \
                    port:py${python.version}-last \
                    port:py${python.version}-mpd2 \
                    port:py${python.version}-discogs-client \
                    port:py${python.version}-pyxdg \
                    port:py${python.version}-rarfile \
                    port:py${python.version}-reflink \
                    port:py${python.version}-requests \
                    port:py${python.version}-resampy \
                    port:py${python.version}-requests-oauthlib \
                    port:py${python.version}-soco

    # 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}-flask \
                    port:py${python.version}-mock \
                    port:py${python.version}-responses

    # Building the man pages for the -devel port currently fails, so skip this as well for now...
    if {${name} eq ${subport}} {
        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
} 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.13.3
    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  a045e114090354a011357953a96bed0fec460908 \
                    sha256  f97e303d0213dc7646159034e8c83cef2b587beca26958a043334192c24c4567 \
                    size    15659

    extract.rename  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        0

    # 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        0

    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.6
    revision        0

    license         MIT

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

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

    distname        beets_autofix-${version}

    checksums       rmd160  b1483497286026e406096dc252ff032b9a642559 \
                    sha256  bc3fd602782dfee06552e68db2f10d768827ad2c670a149e926c80f1247f7d81 \
                    size    11516

    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        0

    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.22.0
    revision        0

    license         GPL-2

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

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

    checksums       rmd160  092d7c0bde90bee1ae3e3d4930bccc720a87b697 \
                    sha256  8529846a6456e8bbcfeab3a1e33cce209f4b9b6161ca4a4817010e81571a8125 \
                    size    50003

    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.5.9
    revision        0

    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

    distname        beets_bpmanalyser-${version}

    checksums       rmd160  cd6816128cad6d67165c5f9789dfe0df4b401f71 \
                    sha256  8965d210b1911c8e1a93531358249d462c8fcfad7c7f2052ccac3f15e262819e \
                    size    8179

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

subport ${name}-check {
    version         0.15.0
    revision        0

    license         MIT

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

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

    distname        beets_check-${version}

    checksums       rmd160  2a9fcb788cec5f3e7e526ef2828b5b3484b60729 \
                    sha256  7f61d5d0f8fd3348bd01acc5b91e6807daf02c488701c94bb6e777c08886acd5 \
                    size    14838
}

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.5
    revision        0

    license         MIT

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

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

    distname        beets_describe-${version}

    checksums       rmd160  55829e93ac7d5d68cc177d31539298e92b96d014 \
                    sha256  a0425c6190fe2a35554589a629482c39b83e029ce149018007109fdd2ada822c \
                    size    8308

    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        0

    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.10
    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  38ba506734fa427aa12c0222f47af2a298446676 \
                    sha256  f9dfdb93755ee87158a977828b6d2b2322d913528eef0df509e63612fd9205f1 \
                    size    21200

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

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

    # 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.3 v
    github.tarball_from archive
    revision        0

    license         MIT

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

    checksums       rmd160  324bb7d0fd592226c81cbf009a9832b1fbbdf48f \
                    sha256  85b56fdd52da1d12af76e54f4b50a1fc396ec8239e7136b75f435a3cd6e44e86 \
                    size    6310
}

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

    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        0

    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        0

    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 993f74bb7920076e0ca41fbb72e9a784c69314ba
    github.tarball_from archive
    version         20250531
    revision        0

    license         LGPL-3

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

    checksums       rmd160  c66738f00211d25958d11d7eea6d8181d369644a \
                    sha256  9fc21aca9ad33ea2a99dafaea965001dbd11af19b61d3a6105ae3e4770f608c8 \
                    size    13531

    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 8eb5c740fc45dbc454b8d53e7554023b561dee85
    github.tarball_from archive
    version         20240311
    revision        0

    license         MIT

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

    checksums       rmd160  ebc817f232f8355d993fcece32c0a310ad12a9d3 \
                    sha256  32da499869f25b39c59cfe21e97873c1c29752722bcb73d938673d272048c88e \
                    size    2661
}

subport ${name}-xtractor {
    version         0.4.2
    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

    distname        beets_xtractor-${version}

    checksums       rmd160  2a7106cb2c0973f23520357ea458093af39a1e46 \
                    sha256  c27db929ec248f4a13f815672c5b8968b01b6462e40367aee9b805d6b5931889 \
                    size    11278

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

subport ${name}-yearfixer {
    version         0.0.5
    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

    distname        beets_yearfixer-${version}

    checksums       rmd160  85237e1ef1da10c98d428fe7efd28e237a310e97 \
                    sha256  e08bb0ae099b2bde1d9dad08680e4cf9820eac3fe6a9794f299e76c9e83c5ac5 \
                    size    6863

    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
}
