-
-
Notifications
You must be signed in to change notification settings - Fork 198
Add WebDAV provider #2484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
OzGav
wants to merge
11
commits into
dev
Choose a base branch
from
webdav
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add WebDAV provider #2484
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3924005
Add webdav provider
OzGav 8d744b9
Merge branch 'dev' into webdav
marcelveldt 7f9cfd8
PR Review
OzGav 6bfceaa
Remove redundant methods
OzGav 7a69aea
use multipartpath
OzGav 00b92df
Remove more redundancy
OzGav c2dc2ae
Refactor to reduce duplication
OzGav b4952ee
refactoring
OzGav d382776
major refactor
OzGav 6dbc10b
Remove unused import
OzGav 96e2abd
Lint
OzGav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """WebDAV filesystem provider for Music Assistant.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption | ||
| from music_assistant_models.enums import ConfigEntryType, ProviderFeature | ||
|
|
||
| from music_assistant.constants import CONF_PASSWORD, CONF_USERNAME | ||
|
|
||
| from .constants import CONF_CONTENT_TYPE, CONF_URL, CONF_VERIFY_SSL | ||
| from .provider import WebDAVFileSystemProvider | ||
|
|
||
| if TYPE_CHECKING: | ||
| from music_assistant_models.config_entries import ConfigValueType, ProviderConfig | ||
| from music_assistant_models.provider import ProviderManifest | ||
|
|
||
| from music_assistant.mass import MusicAssistant | ||
| from music_assistant.models import ProviderInstanceType | ||
|
|
||
|
|
||
| # Supported features | ||
| SUPPORTED_FEATURES = { | ||
| ProviderFeature.BROWSE, | ||
| ProviderFeature.SEARCH, | ||
| } | ||
|
|
||
|
|
||
| async def setup( | ||
| mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig | ||
| ) -> ProviderInstanceType: | ||
| """Initialize provider(instance) with given configuration.""" | ||
| prov = WebDAVFileSystemProvider(mass, manifest, config) | ||
| await prov.handle_async_init() | ||
| return prov | ||
|
|
||
|
|
||
| async def get_config_entries( | ||
| mass: MusicAssistant, | ||
| instance_id: str | None = None, | ||
| action: str | None = None, | ||
| values: dict[str, ConfigValueType] | None = None, | ||
| ) -> tuple[ConfigEntry, ...]: | ||
| """Return Config entries to setup this provider.""" | ||
| # ruff: noqa: ARG001 | ||
| return ( | ||
| ConfigEntry( | ||
| key=CONF_CONTENT_TYPE, | ||
| type=ConfigEntryType.STRING, | ||
| label="Content type", | ||
| options=[ | ||
| ConfigValueOption("Music", "music"), | ||
| ConfigValueOption("Audiobooks", "audiobooks"), | ||
| ConfigValueOption("Podcasts", "podcasts"), | ||
| ], | ||
| default_value="music", | ||
| description="The type of content stored on this WebDAV server", | ||
| hidden=instance_id is not None, | ||
| ), | ||
| ConfigEntry( | ||
| key=CONF_URL, | ||
| type=ConfigEntryType.STRING, | ||
| label="WebDAV URL", | ||
| required=True, | ||
| description="The base URL of your WebDAV server (e.g., https://example.com/webdav)", | ||
| ), | ||
| ConfigEntry( | ||
| key=CONF_USERNAME, | ||
| type=ConfigEntryType.STRING, | ||
| label="Username", | ||
| required=False, | ||
| description="Username for WebDAV authentication (leave empty for no authentication)", | ||
| ), | ||
| ConfigEntry( | ||
| key=CONF_PASSWORD, | ||
| type=ConfigEntryType.SECURE_STRING, | ||
| label="Password", | ||
| required=False, | ||
| description="Password for WebDAV authentication", | ||
| ), | ||
| ConfigEntry( | ||
| key=CONF_VERIFY_SSL, | ||
| type=ConfigEntryType.BOOLEAN, | ||
| label="Verify SSL certificate", | ||
| default_value=False, | ||
| description="Verify SSL certificates when connecting to HTTPS WebDAV servers", | ||
| ), | ||
| ConfigEntry( | ||
| key="missing_album_artist_action", | ||
| type=ConfigEntryType.STRING, | ||
| label="Action when album artist tag is missing", | ||
| options=[ | ||
| ConfigValueOption("Use track artist(s)", "track_artist"), | ||
| ConfigValueOption("Use folder name", "folder_name"), | ||
| ConfigValueOption("Use 'Various Artists'", "various_artists"), | ||
| ], | ||
| default_value="various_artists", | ||
| description="What to do when a track is missing the album artist tag", | ||
| ), | ||
OzGav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ConfigEntry( | ||
| key="ignore_album_playlists", | ||
| type=ConfigEntryType.BOOLEAN, | ||
| label="Ignore playlists in album folders", | ||
| default_value=True, | ||
| description="Ignore playlist files found in album subdirectories", | ||
| ), | ||
OzGav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """WebDAV File System Provider constants.""" | ||
|
|
||
| from typing import Final | ||
|
|
||
| # Only WebDAV-specific constants | ||
| CONF_URL: Final[str] = "url" | ||
| CONF_VERIFY_SSL: Final[str] = "verify_ssl" | ||
| CONF_CONTENT_TYPE: Final[str] = "content_type" # This one stays - it's in config | ||
| MAX_CONCURRENT_TASKS: Final[int] = 5 | ||
| WEBDAV_TIMEOUT: Final[int] = 30 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.