Skip to content

Commit

Permalink
complete restructure + remove named args on __call__ (#49)
Browse files Browse the repository at this point in the history
* complete restructure + remove named args on __call__

* update release history

* update json schema file

* update logging config
  • Loading branch information
geo-martino authored Mar 29, 2024
1 parent 0ac030d commit 4ca7de1
Show file tree
Hide file tree
Showing 185 changed files with 1,250 additions and 1,294 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith
> Libraries log info about loaded objects to the custom `STAT` level.
> ```python
> import logging
> from musify.shared.logger import STAT
> from musify.log import STAT
>
> logging.basicConfig(format="%(message)s", level=STAT)
> ```
Expand All @@ -80,7 +81,7 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith
> The scopes listed in this example will allow access to read your library data and write to your playlists.
> See Spotify Web API documentation for more information about [scopes](https://developer.spotify.com/documentation/web-api/concepts/scopes)
```python
from musify.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.api import SpotifyAPI
api = SpotifyAPI(
client_id="<YOUR CLIENT ID>",
Expand All @@ -103,7 +104,7 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith
```
4. Create a `SpotifyLibrary` object and load your library data as follows:
```python
from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.library import SpotifyLibrary
library = SpotifyLibrary(api=api)
Expand Down Expand Up @@ -133,7 +134,7 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith
```
5. Load some Spotify objects using any of the supported identifiers as follows:
```python
from musify.spotify.object import SpotifyTrack, SpotifyAlbum, SpotifyPlaylist, SpotifyArtist
from musify.libraries.remote.spotify.object import SpotifyTrack, SpotifyAlbum, SpotifyPlaylist, SpotifyArtist
# load by ID
track1 = SpotifyTrack.load("6fWoFduMpBem73DMLCOh1Z", api=api)
Expand Down Expand Up @@ -181,7 +182,7 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith

#### Generic local library
```python
from musify.local.library import LocalLibrary
from musify.libraries.local.library import LocalLibrary

library = LocalLibrary(
library_folders=["<PATH TO YOUR LIBRARY FOLDER>", ...],
Expand All @@ -191,7 +192,7 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith

#### MusicBee
```python
from musify.local.library import MusicBee
from musify.libraries.local.library import MusicBee

library = MusicBee(musicbee_folder="<PATH TO YOUR MUSICBEE FOLDER>")
```
Expand Down Expand Up @@ -228,7 +229,8 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith
4. Get a track from your library using any of the following identifiers:
```python
# get a track via its title
track = library["<TRACK TITLE>"] # if multiple tracks have the same title, the first matching one if returned
# if multiple tracks have the same title, the first matching one if returned
track = library["<TRACK TITLE>"]

# get a track via its path
track = library["<PATH TO YOUR TRACK>"] # must be an absolute path
Expand Down Expand Up @@ -265,7 +267,7 @@ For more detailed guides, check out the [documentation](https://geo-martino.gith

6. Save the tags to the file:
```python
from musify.local.track.field import LocalTrackField
from musify.libraries.local.track.field import LocalTrackField

# you don't have to save all the tags you just modified
# select which you wish to save first like so
Expand Down
18 changes: 10 additions & 8 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ For more detailed guides, check out the [documentation](https://{program_owner_u
> Libraries log info about loaded objects to the custom `STAT` level.
> ```python
> import logging
> from musify.shared.logger import STAT
> from musify.log import STAT
>
> logging.basicConfig(format="%(message)s", level=STAT)
> ```
Expand All @@ -80,7 +81,7 @@ For more detailed guides, check out the [documentation](https://{program_owner_u
> The scopes listed in this example will allow access to read your library data and write to your playlists.
> See Spotify Web API documentation for more information about [scopes](https://developer.spotify.com/documentation/web-api/concepts/scopes)
```python
from musify.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.api import SpotifyAPI
api = SpotifyAPI(
client_id="<YOUR CLIENT ID>",
Expand All @@ -103,7 +104,7 @@ For more detailed guides, check out the [documentation](https://{program_owner_u
```
4. Create a `SpotifyLibrary` object and load your library data as follows:
```python
from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.library import SpotifyLibrary
library = SpotifyLibrary(api=api)
Expand Down Expand Up @@ -133,7 +134,7 @@ For more detailed guides, check out the [documentation](https://{program_owner_u
```
5. Load some Spotify objects using any of the supported identifiers as follows:
```python
from musify.spotify.object import SpotifyTrack, SpotifyAlbum, SpotifyPlaylist, SpotifyArtist
from musify.libraries.remote.spotify.object import SpotifyTrack, SpotifyAlbum, SpotifyPlaylist, SpotifyArtist
# load by ID
track1 = SpotifyTrack.load("6fWoFduMpBem73DMLCOh1Z", api=api)
Expand Down Expand Up @@ -181,7 +182,7 @@ For more detailed guides, check out the [documentation](https://{program_owner_u

#### Generic local library
```python
from musify.local.library import LocalLibrary
from musify.libraries.local.library import LocalLibrary

library = LocalLibrary(
library_folders=["<PATH TO YOUR LIBRARY FOLDER>", ...],
Expand All @@ -191,7 +192,7 @@ For more detailed guides, check out the [documentation](https://{program_owner_u

#### MusicBee
```python
from musify.local.library import MusicBee
from musify.libraries.local.library import MusicBee

library = MusicBee(musicbee_folder="<PATH TO YOUR MUSICBEE FOLDER>")
```
Expand Down Expand Up @@ -228,7 +229,8 @@ For more detailed guides, check out the [documentation](https://{program_owner_u
4. Get a track from your library using any of the following identifiers:
```python
# get a track via its title
track = library["<TRACK TITLE>"] # if multiple tracks have the same title, the first matching one if returned
# if multiple tracks have the same title, the first matching one if returned
track = library["<TRACK TITLE>"]

# get a track via its path
track = library["<PATH TO YOUR TRACK>"] # must be an absolute path
Expand Down Expand Up @@ -265,7 +267,7 @@ For more detailed guides, check out the [documentation](https://{program_owner_u

6. Save the tags to the file:
```python
from musify.local.track.field import LocalTrackField
from musify.libraries.local.track.field import LocalTrackField

# you don't have to save all the tags you just modified
# select which you wish to save first like so
Expand Down
4 changes: 2 additions & 2 deletions docs/_howto/scripts/local.library.backup-restore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from musify.local.library import LocalLibrary
from musify.libraries.local.library import LocalLibrary
library = LocalLibrary()

import json
Expand All @@ -13,7 +13,7 @@

library.restore_tracks(tracks)

from musify.local.track.field import LocalTrackField
from musify.libraries.local.track.field import LocalTrackField

tags = [
LocalTrackField.TITLE,
Expand Down
4 changes: 2 additions & 2 deletions docs/_howto/scripts/local.library.load.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from musify.local.library import LocalLibrary
from musify.libraries.local.library import LocalLibrary

library = LocalLibrary(
library_folders=["<PATH TO YOUR LIBRARY FOLDER>", ...],
playlist_folder="<PATH TO YOUR PLAYLIST FOLDER>",
)

from musify.local.library import MusicBee
from musify.libraries.local.library import MusicBee

library = MusicBee(musicbee_folder="<PATH TO YOUR MUSICBEE FOLDER>")

Expand Down
12 changes: 6 additions & 6 deletions docs/_howto/scripts/local.playlist.load-save.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from musify.local.playlist import M3U, XAutoPF
from musify.local.track import load_track
from musify.libraries.local.playlist import M3U, XAutoPF
from musify.libraries.local.track import load_track

tracks = [
load_track("<PATH TO A TRACK>"),
Expand All @@ -16,11 +16,11 @@
# pretty print information about this playlist
print(playlist)

from musify.local.playlist import load_playlist
from musify.libraries.local.playlist import load_playlist

playlist = load_playlist("<PATH TO A PLAYLIST>")

from musify.local.track import load_track
from musify.libraries.local.track import load_track

tracks = [
load_track("<PATH TO A TRACK>"),
Expand All @@ -31,11 +31,11 @@

playlist = M3U("<PATH TO AN M3U PLAYLIST>", tracks=tracks)

from musify.shared.file import PathMapper
from musify.file.path_mapper import PathMapper

playlist = M3U("<PATH TO AN M3U PLAYLIST>", path_mapper=PathMapper())

from musify.spotify.processors import SpotifyDataWrangler
from musify.libraries.remote.spotify.processors import SpotifyDataWrangler

playlist = M3U("<PATH TO AN M3U PLAYLIST>", remote_wrangler=SpotifyDataWrangler())

Expand Down
8 changes: 4 additions & 4 deletions docs/_howto/scripts/local.track.load-save.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from musify.local.track import FLAC, MP3, M4A, WMA
from musify.libraries.local.track import FLAC, MP3, M4A, WMA

track = FLAC("<PATH TO A FLAC TRACK>")
track = MP3("<PATH TO AN MP3 TRACK>")
Expand All @@ -8,11 +8,11 @@
# pretty print information about this track
print(track)

from musify.local.track import load_track
from musify.libraries.local.track import load_track

track = load_track("<PATH TO AN MP3 TRACK>")

from musify.spotify.processors import SpotifyDataWrangler
from musify.libraries.remote.spotify.processors import SpotifyDataWrangler

track = MP3("<PATH TO AN MP3 TRACK>", remote_wrangler=SpotifyDataWrangler())

Expand All @@ -39,7 +39,7 @@
results = track.save(replace=True, dry_run=False)

# ...or select which tags you wish to save like so
from musify.local.track.field import LocalTrackField
from musify.libraries.local.track.field import LocalTrackField

tags = [
LocalTrackField.TITLE,
Expand Down
8 changes: 4 additions & 4 deletions docs/_howto/scripts/remote.new-music.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from musify.spotify.api import SpotifyAPI
from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.library import SpotifyLibrary
api = SpotifyAPI()
library = SpotifyLibrary(api=api)

Expand All @@ -23,7 +23,7 @@ def match_date(alb) -> bool:
return False


from musify.shared.remote.enum import RemoteObjectType
from musify.libraries.remote.core.enum import RemoteObjectType

albums = [album for artist in library.artists for album in artist.albums if match_date(album)]
albums_need_extend = [album for album in albums if len(album.tracks) < album.track_total]
Expand All @@ -39,7 +39,7 @@ def match_date(alb) -> bool:
# log stats about the loaded artists
library.log_artists()

from musify.spotify.object import SpotifyPlaylist
from musify.libraries.remote.spotify.object import SpotifyPlaylist

name = "New Music Playlist"
playlist = SpotifyPlaylist.create(api=api, name=name)
Expand Down
8 changes: 4 additions & 4 deletions docs/_howto/scripts/reports.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from musify.local.library import LocalLibrary
from musify.libraries.local.library import LocalLibrary
local_library = LocalLibrary()

from musify.spotify.api import SpotifyAPI
from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.library import SpotifyLibrary
api = SpotifyAPI()
remote_library = SpotifyLibrary(api=api)

from musify.report import report_playlist_differences

report_playlist_differences(source=local_library, reference=remote_library)

from musify.local.track.field import LocalTrackField
from musify.libraries.local.track.field import LocalTrackField
from musify.report import report_missing_tags

tags = [
Expand Down
2 changes: 1 addition & 1 deletion docs/_howto/scripts/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging
from musify.shared.logger import STAT
from musify.log import STAT

logging.basicConfig(format="%(message)s", level=STAT)
4 changes: 2 additions & 2 deletions docs/_howto/scripts/spotify.api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from musify.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.api import SpotifyAPI

api = SpotifyAPI(
client_id="<YOUR CLIENT ID>",
Expand All @@ -19,5 +19,5 @@
# authorise the program to access your Spotify data in your web browser
api.authorise()

from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.library import SpotifyLibrary
library = SpotifyLibrary(api=api)
4 changes: 2 additions & 2 deletions docs/_howto/scripts/spotify.library.backup-restore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from musify.spotify.api import SpotifyAPI
from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.library import SpotifyLibrary
api = SpotifyAPI()
library = SpotifyLibrary(api=api)

Expand Down
6 changes: 3 additions & 3 deletions docs/_howto/scripts/spotify.load.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from musify.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.api import SpotifyAPI
api = SpotifyAPI()

from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.library import SpotifyLibrary

library = SpotifyLibrary(api=api)

Expand Down Expand Up @@ -29,7 +29,7 @@
# pretty print an overview of your library
print(library)

from musify.spotify.object import SpotifyTrack, SpotifyAlbum, SpotifyPlaylist, SpotifyArtist
from musify.libraries.remote.spotify.object import SpotifyTrack, SpotifyAlbum, SpotifyPlaylist, SpotifyArtist

# load by ID
track1 = SpotifyTrack.load("6fWoFduMpBem73DMLCOh1Z", api=api)
Expand Down
16 changes: 8 additions & 8 deletions docs/_howto/scripts/sync.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from musify.spotify.api import SpotifyAPI
from musify.libraries.remote.spotify.api import SpotifyAPI
api = SpotifyAPI()

from musify.local.library import LocalLibrary
from musify.spotify.processors import SpotifyDataWrangler
from musify.libraries.local.library import LocalLibrary
from musify.libraries.remote.spotify.processors import SpotifyDataWrangler

local_library = LocalLibrary(
library_folders=["<PATH TO YOUR LIBRARY FOLDER>", ...],
Expand All @@ -12,9 +12,9 @@
)
local_library.load()

from musify.shared.remote.processors.search import RemoteItemSearcher
from musify.shared.remote.processors.check import RemoteItemChecker
from musify.spotify.factory import SpotifyObjectFactory
from musify.libraries.remote.core.processors.search import RemoteItemSearcher
from musify.libraries.remote.core.processors.check import RemoteItemChecker
from musify.libraries.remote.spotify.factory import SpotifyObjectFactory

albums = local_library.albums[:3]
factory = SpotifyObjectFactory(api=api)
Expand All @@ -25,7 +25,7 @@
checker = RemoteItemChecker(object_factory=factory)
checker.check(albums)

from musify.spotify.object import SpotifyTrack
from musify.libraries.remote.spotify.object import SpotifyTrack

for album in albums:
for local_track in album:
Expand All @@ -46,7 +46,7 @@
# ...save all tracks on the album at once here
album.save_tracks(replace=True, dry_run=False)

from musify.spotify.library import SpotifyLibrary
from musify.libraries.remote.spotify.library import SpotifyLibrary

remote_library = SpotifyLibrary(api=api)
remote_library.load_playlists()
Expand Down
12 changes: 9 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ Install through pip using one of the following commands:
:maxdepth: 1
:caption: 📖 Reference

musify.local
musify.api
musify.core
musify.file
musify.libraries
musify.log
musify.processors
musify.shared
musify.spotify
musify.exception
musify.field
musify.report
musify.types
musify.utils
genindex
Loading

0 comments on commit 4ca7de1

Please sign in to comment.