Skip to content

Commit

Permalink
Rename soundcloud package
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Dec 15, 2024
1 parent de2f825 commit 1fbb1b8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions beetsplug/bandcamp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get(self, album: AlbumInfo, *_: Any) -> Iterable[fetchart.Candidate]:
)


class BandcampPlugin(BandcampRequestsHandler, plugins.BeetsPlugin):
class SoundcloudPlugin(BandcampRequestsHandler, plugins.BeetsPlugin):
MAX_COMMENT_LENGTH = 4047
ALBUM_SLUG_IN_TRACK = cached_patternprop(r'(?<=<a id="buyAlbumLink" href=")[^"]+')
LABEL_URL_IN_COMMENT = cached_patternprop(r"Visit (https:[\w/.-]+\.[a-z]+)")
Expand Down Expand Up @@ -456,7 +456,7 @@ def main() -> None:
else:
print(json.dumps(search_results))
else:
pl = BandcampPlugin()
pl = SoundcloudPlugin()
pl._log.setLevel(10)
url = args.release_url
if result := pl.get_album_info(args.release_url) or pl.get_track_info(url):
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[tool.poetry]
name = "beetcamp"
version = "0.21.0"
description = "Bandcamp autotagger source for beets (http://beets.io)."
name = "beets-soundcloud"
version = "0.1.0"
description = "Soundcloud autotagger source for beets (http://beets.io)."
authors = ["Šarūnas Nejus <[email protected]>"]
readme = "README.md"
license = "GPL-2.0"
homepage = "https://github.com/snejus/beetcamp"
repository = "https://github.com/snejus/beetcamp"

packages = [{ include = "beetsplug" }]
packages = [{ include = "beetsplug", to = "soundcloud" }]
include = ["LICENSE", "README.md"]

keywords = ["music", "bandcamp", "beets", "metadata"]
classifiers = [
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Operating System :: OS Independent",
"Topic :: Multimedia :: Sound/Audio",
"Topic :: Text Processing :: General",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Operating System :: OS Independent",
"Topic :: Multimedia :: Sound/Audio",
"Topic :: Text Processing :: General",
]

[tool.poetry.urls]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
from typing_extensions import TypedDict

from beetsplug.bandcamp import BandcampPlugin
from beetsplug.bandcamp import SoundcloudPlugin
from beetsplug.bandcamp.metaguru import Metaguru

if TYPE_CHECKING:
Expand Down Expand Up @@ -335,7 +335,7 @@ def target_dir(pytestconfig: Config) -> Path:

@pytest.fixture(scope="module")
def config() -> JSONDict:
return dict(BandcampPlugin().config.flatten())
return dict(SoundcloudPlugin().config.flatten())


@pytest.fixture(params=sorted(JSONS_DIR.glob("*.json")), ids=str)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from beets.library import Item
from beets.plugins import log

from beetsplug.bandcamp import DEFAULT_CONFIG, BandcampAlbumArt, BandcampPlugin
from beetsplug.bandcamp import DEFAULT_CONFIG, BandcampAlbumArt, SoundcloudPlugin

LABEL_URL = "https://label.bandcamp.com"
ALBUM_URL = f"{LABEL_URL}/album/release"
Expand Down Expand Up @@ -35,7 +35,7 @@ def check_album(actual, expected):
],
)
def test_parse_label_url_in_comments(comments, expected_url):
assert BandcampPlugin.parse_label_url(comments) == expected_url
assert SoundcloudPlugin.parse_label_url(comments) == expected_url


@pytest.mark.parametrize(
Expand All @@ -62,21 +62,21 @@ def test_parse_label_url_in_comments(comments, expected_url):
def test_find_url(mb_albumid, comments, album, expected_url):
"""URLs in `mb_albumid` and `comments` fields must be found."""
item = Item(mb_albumid=mb_albumid, comments=comments)
assert BandcampPlugin()._find_url_in_item(item, album, "album") == expected_url
assert SoundcloudPlugin()._find_url_in_item(item, album, "album") == expected_url


@pytest.fixture
def plugin(monkeypatch, bandcamp_html):
monkeypatch.setattr(BandcampPlugin, "_get", lambda *args: bandcamp_html)
pl = BandcampPlugin()
monkeypatch.setattr(SoundcloudPlugin, "_get", lambda *args: bandcamp_html)
pl = SoundcloudPlugin()
pl.config.set(DEFAULT_CONFIG)
return pl


@pytest.mark.parametrize("method", ["album_for_id", "track_for_id"])
def test_handle_non_bandcamp_url(method):
"""The plugin should not break if a non-bandcamp URL is presented."""
assert getattr(BandcampPlugin(), method)("https://www.some-random-url") is None
assert getattr(SoundcloudPlugin(), method)("https://www.some-random-url") is None


@pytest.mark.parametrize(
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_singleton_candidates(plugin, expected_release):


def test_bandcamp_plugin_name():
assert BandcampPlugin().data_source == "bandcamp"
assert SoundcloudPlugin().data_source == "bandcamp"


@pytest.fixture
Expand Down
6 changes: 3 additions & 3 deletions tests/test_real_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from beetsplug.bandcamp import BandcampPlugin
from beetsplug.bandcamp import SoundcloudPlugin

pytestmark = pytest.mark.need_connection

Expand All @@ -12,7 +12,7 @@ def test_get_html():
url = "https://ute-rec.bandcamp.com/album/ute004"
should_contain = "UTE004 by Mikkel Rev, released 17 July 2020"

plugin = BandcampPlugin()
plugin = SoundcloudPlugin()
html = plugin._get(url)

assert html
Expand All @@ -23,7 +23,7 @@ def test_return_none_for_gibberish():
"""Check whether None is being returned."""
url = "https://ute-rec.bandcamp.com/somegibberish2113231"

plugin = BandcampPlugin()
plugin = SoundcloudPlugin()
html = plugin._get(url)

assert not html

0 comments on commit 1fbb1b8

Please sign in to comment.