Search for stuff on Bandcamp
Go to file
Ian Fijolek 69306c551b
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Disable tests
2024-10-15 09:16:30 -07:00
bandcamp_search Run hooks 2024-10-15 09:15:35 -07:00
.drone.star Working commit 2024-10-15 09:07:27 -07:00
.gitignore Run hooks 2024-10-15 09:15:35 -07:00
.pre-commit-config.yaml Working commit 2024-10-15 09:07:27 -07:00
LICENSE Initial commit 2024-10-15 16:05:53 +00:00
Makefile Disable tests 2024-10-15 09:16:30 -07:00
poetry.lock Relax python version 2024-10-15 09:13:21 -07:00
pyproject.toml Relax python version 2024-10-15 09:13:21 -07:00
README.md Working commit 2024-10-15 09:07:27 -07:00

bandcamp-search

Library to search for music on Bandcamp.

Installation

pip install bandcamp-search

Usage

Sample usage is in bandcamp_search/__main__.py:

import sys
from typing import cast

from bandcamp_search.search import search
from bandcamp_search.models import (
    AlbumSearchResult,
    ArtistLabelSearchResult,
    SearchType,
    TrackSearchResult,
)

if __name__ == "__main__":
    query = sys.argv[1]
    results = search(query, SearchType.ALL)
    for result in results["auto"]["results"]:
        if result["type"] == SearchType.ALBUMS:
            result = cast(AlbumSearchResult, result)
            print(f"Album: {result['name']}")
            print(f"  by {result['band_name']}")
            print(f"  buy at {result['item_url_path']}")
        if result["type"] == SearchType.ARTISTS_AND_LABELS:
            result = cast(ArtistLabelSearchResult, result)
            print("Artist/Label: {result['name']}")
            print(f"  {result['location']}")
        if result["type"] == SearchType.TRACKS:
            result = cast(TrackSearchResult, result)
            print(f"Track: {result['name']}")
            print(f"  on {result['album_name']} by {result['band_name']}")
            print(f"  listen at {result['item_url_path']}")