pymonomusic 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ Copyright © 2026 lostssss
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymonomusic
3
+ Version: 1.0.0
4
+ Summary: Python bindings for the Monochrome Tracks API.
5
+ Author-email: lostssss <imaginegameservice@gmail.com>
6
+ Project-URL: Homepage, https://github.com/LostShadowGD/pymonomusic
7
+ Keywords: music,downloader
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.0.0
14
+ Dynamic: license-file
15
+
16
+ # pymonomusic
17
+
18
+ Python bindings for the Monochrome Tracks API.
19
+
20
+ ## Usage
21
+
22
+ ### Get track stream URL
23
+ ```
24
+ import pymonomusic
25
+ client = MonochromeClient()
26
+ stream = client.streamTrack(166114521845624832)
27
+ ```
28
+
29
+ ### Search Tracks
30
+ ```
31
+ import pymonomusic
32
+ client = MonochromeClient()
33
+ searchResults = client.search("Cavetown")
34
+ tracks = searchResults.tracks
35
+ ```
@@ -0,0 +1,20 @@
1
+ # pymonomusic
2
+
3
+ Python bindings for the Monochrome Tracks API.
4
+
5
+ ## Usage
6
+
7
+ ### Get track stream URL
8
+ ```
9
+ import pymonomusic
10
+ client = MonochromeClient()
11
+ stream = client.streamTrack(166114521845624832)
12
+ ```
13
+
14
+ ### Search Tracks
15
+ ```
16
+ import pymonomusic
17
+ client = MonochromeClient()
18
+ searchResults = client.search("Cavetown")
19
+ tracks = searchResults.tracks
20
+ ```
@@ -0,0 +1,157 @@
1
+ import requests
2
+ from urllib.parse import quote
3
+
4
+ class Track:
5
+ def __init__(self, trackDict: dict):
6
+ self.id = trackDict.get("id") if trackDict.get("id") is not None else trackDict.get("trackId")
7
+ self.title = trackDict.get("title")
8
+ self.releaseId = trackDict.get("releaseId")
9
+ self.artwork = trackDict.get("artwork")
10
+ self.explicit = trackDict.get("explicit")
11
+ self.playable = trackDict.get("playable")
12
+ self.duration = trackDict.get("duration") / 1000 if trackDict.get("duration") is not None else None
13
+ self.isrc = trackDict.get("isrc")
14
+ self.recordingId = trackDict.get("recordingId")
15
+
16
+ # from search only
17
+ self.artistIds = trackDict.get("artistIds")
18
+ self.artistNames = trackDict.get("artistNames")
19
+ self.searchPriority = trackDict.get("searchPriority")
20
+
21
+ # from releases only
22
+ self.artists = [Artist(artist) for artist in trackDict.get("artists")] if trackDict.get("artists") is not None else None
23
+ self.discNumber = trackDict.get("discNumber")
24
+ self.trackNumber = trackDict.get("trackNumber")
25
+
26
+ def __repr__(self):
27
+ return f"Track(id={int(self.id)!r}, title={self.title!r})"
28
+
29
+ class Artist:
30
+ def __init__(self, artistDict: dict):
31
+ self.id = artistDict.get("id") if artistDict.get("id") is not None else artistDict.get("artistId")
32
+ self.name = artistDict.get("name")
33
+ self.username = artistDict.get("username")
34
+ self.displayName = artistDict.get("displayName")
35
+ self.sortName = artistDict.get("sortName")
36
+ self.avatar = artistDict.get("avatar")
37
+ self.bio = artistDict.get("bio")
38
+
39
+ # from search only
40
+ self.searchPriority = artistDict.get("searchPriority")
41
+
42
+ # from page only
43
+ self.alias = artistDict.get("alias")
44
+ self.createdAt = artistDict.get("createdAt")
45
+ self.updatedAt = artistDict.get("updatedAt")
46
+ self.alternateNames = artistDict.get("alternateNames")
47
+ self.isVerified = artistDict.get("isVerified")
48
+ self.status = artistDict.get("status")
49
+ self.entropyOrchestrationResolution = artistDict.get("entropyOrchestrationResolution")
50
+ self.biography = artistDict.get("biography")
51
+ self.dateOfBirth = artistDict.get("dateOfBirth")
52
+ self.dateOfDeath = artistDict.get("dateOfDeath")
53
+ self.country = artistDict.get("country")
54
+ self.city = artistDict.get("city")
55
+ self.banner = artistDict.get("banner")
56
+ self.externalLink = artistDict.get("externalLink")
57
+ self.socialLinks = artistDict.get("socialLinks")
58
+ self.genres = artistDict.get("genres")
59
+ self.tags = artistDict.get("tags")
60
+
61
+ self.latestRelease = Release(artistDict.get("latestRelease")) if artistDict.get("latestRelease") is not None else None
62
+ self.topTracks = [Track(track) for track in artistDict.get("topTracks")] if artistDict.get("topTracks") is not None else None
63
+ self.releases = [Release(release) for release in artistDict.get("releases")] if artistDict.get("releases") is not None else None
64
+ self.albums = [Release(release) for release in artistDict.get("albums")] if artistDict.get("albums") is not None else None
65
+ self.singles = [Release(release) for release in artistDict.get("singles")] if artistDict.get("singles") is not None else None
66
+
67
+ def __repr__(self):
68
+ return f"Artist(id={int(self.id)!r}, name={self.name!r}, username={self.username!r})"
69
+
70
+ class Release:
71
+ def __init__(self, releaseDict: dict):
72
+ self.id = releaseDict.get("id") if releaseDict.get("id") is not None else releaseDict.get("releaseId")
73
+ self.title = releaseDict.get("title")
74
+ self.label = releaseDict.get("label")
75
+ self.artwork = releaseDict.get("artwork")
76
+ self.explicit = releaseDict.get("explicit")
77
+
78
+ # from search only
79
+ self.artistIds = releaseDict.get("artistIds")
80
+ self.artistNames = releaseDict.get("artistNames")
81
+ self.releaseDate = releaseDict.get("releaseDate")
82
+ self.releaseType = releaseDict.get("releaseType")
83
+ self.searchPriority = releaseDict.get("searchPriority")
84
+
85
+ # from releases only
86
+ self.artists = [Artist(artist) for artist in releaseDict.get("artists")] if releaseDict.get("artists") is not None else None
87
+ self.upc = releaseDict.get("upc")
88
+ self.discCount = releaseDict.get("discCount")
89
+ self.trackCount = releaseDict.get("trackCount")
90
+ self.language = releaseDict.get("language")
91
+ self.script = releaseDict.get("script")
92
+ self.copyrights = releaseDict.get("copyrights")
93
+ self.createdAt = releaseDict.get("createdAt")
94
+ self.updatedAt = releaseDict.get("updatedAt")
95
+ self.tracks = [Track(track) for track in releaseDict.get("tracks")] if releaseDict.get("tracks") is not None else None
96
+
97
+ def __repr__(self):
98
+ return f"Release(id={int(self.id)!r}, title={self.title!r})"
99
+
100
+ class SearchResults:
101
+ def __init__(self, results: dict):
102
+ self.tracks: list = [Track(track) for track in results["tracks"]]
103
+ self.artists: list = [Artist(artist) for artist in results["artists"]]
104
+ self.releases: list = [Release(release) for release in results["releases"]]
105
+
106
+ class Stream:
107
+ def __init__(self, trackID: int, url: str, bitDepth: int | None, sampleRate: int | None):
108
+ self.id = trackID; self.url = url; self.bitDepth = bitDepth; self.sampleRate = sampleRate
109
+ def __repr__(self):
110
+ return f"Stream(id={int(self.id)!r}, bitDepth={self.bitDepth!r}, sampleRate={self.sampleRate!r})"
111
+
112
+ class MonochromeClient:
113
+ class InvalidFLACHeaderException(Exception):
114
+ """Exception raised when the FLAC's header doesn't match 'fLaC'."""
115
+
116
+ def __init__(self, url):
117
+ super().__init__(f"FLAC from Monochrome ('{url}')'s header doesn't match 'fLaC'.")
118
+
119
+ def streamTrack(self, trackID: int, getFLACInfo: bool = False):
120
+ """Gets streaming info from a trackID."""
121
+ url = f"https://tracks.monochrome.st/track/{trackID}"
122
+ if getFLACInfo:
123
+ with requests.get(url, stream=True) as r:
124
+ r.raise_for_status()
125
+ chunk: bytes = r.raw.read(64)
126
+ if chunk[:4].startswith(b"fLaC"):
127
+ flacSTREAMINFO = chunk[4:38]
128
+ sampleRate = (flacSTREAMINFO[14] << 12) | (flacSTREAMINFO[15] << 4) | (flacSTREAMINFO[16] >> 4)
129
+ bitDepth = (((flacSTREAMINFO[16] & 0x01) << 4) | (flacSTREAMINFO[17] >> 4)) + 1
130
+
131
+ return Stream(trackID, url, bitDepth, sampleRate)
132
+ else: raise MonochromeClient.InvalidFLACHeaderException(url)
133
+ else:
134
+ return Stream(trackID, url, None, None)
135
+
136
+ def search(self, q: str):
137
+ """Searches Monochrome for a query. Returns tracks, artists and releases."""
138
+ r = requests.get(f"https://tracks.monochrome.st/search?q={quote(q)}")
139
+ r.raise_for_status()
140
+ return SearchResults(r.json())
141
+
142
+ def getRelease(self, releaseID: int):
143
+ """Gets detailed information on a release."""
144
+ r = requests.get(f"https://tracks.monochrome.st/releases/{releaseID}")
145
+ r.raise_for_status()
146
+ return Release(r.json())
147
+
148
+ def getArtist(self, artistID: int):
149
+ """Gets detailed information on an artist."""
150
+ r = requests.get(f"https://tracks.monochrome.st/artists/{artistID}")
151
+ r.raise_for_status()
152
+ return Artist(r.json())
153
+
154
+ def getDonationGoalPercentage(self):
155
+ r = requests.get("https://tracks.monochrome.st/goal")
156
+ r.raise_for_status()
157
+ return int(r.json()["percentage"].replace("%", ""))
@@ -0,0 +1,35 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymonomusic
3
+ Version: 1.0.0
4
+ Summary: Python bindings for the Monochrome Tracks API.
5
+ Author-email: lostssss <imaginegameservice@gmail.com>
6
+ Project-URL: Homepage, https://github.com/LostShadowGD/pymonomusic
7
+ Keywords: music,downloader
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.0.0
14
+ Dynamic: license-file
15
+
16
+ # pymonomusic
17
+
18
+ Python bindings for the Monochrome Tracks API.
19
+
20
+ ## Usage
21
+
22
+ ### Get track stream URL
23
+ ```
24
+ import pymonomusic
25
+ client = MonochromeClient()
26
+ stream = client.streamTrack(166114521845624832)
27
+ ```
28
+
29
+ ### Search Tracks
30
+ ```
31
+ import pymonomusic
32
+ client = MonochromeClient()
33
+ searchResults = client.search("Cavetown")
34
+ tracks = searchResults.tracks
35
+ ```
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ pymonomusic/main.py
5
+ pymonomusic.egg-info/PKG-INFO
6
+ pymonomusic.egg-info/SOURCES.txt
7
+ pymonomusic.egg-info/dependency_links.txt
8
+ pymonomusic.egg-info/requires.txt
9
+ pymonomusic.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.0.0
@@ -0,0 +1 @@
1
+ pymonomusic
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pymonomusic"
7
+ version = "1.0.0"
8
+ description = "Python bindings for the Monochrome Tracks API."
9
+ readme = "README.md"
10
+ authors = [{ name = "lostssss", email = "imaginegameservice@gmail.com" }]
11
+ license-files = ["LICENSE"]
12
+ classifiers = [
13
+ "Programming Language :: Python",
14
+ "Programming Language :: Python :: 3",
15
+ ]
16
+ keywords = ["music", "downloader"]
17
+ dependencies = [
18
+ "requests>=2.0.0",
19
+ ]
20
+ requires-python = ">=3.9"
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/LostShadowGD/pymonomusic"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+