Skip to content
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

Load scores from url with raw contents #354

Open
manoskary opened this issue May 13, 2024 · 0 comments
Open

Load scores from url with raw contents #354

manoskary opened this issue May 13, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@manoskary
Copy link
Member

Load score, performance MIDIs, or match files currently works by providing local paths.
I suggest also supporting loading files directly from URLs such as raw content from GitHub.
This could be easily done with no additional dependencies by using urllib. This is the two functions that we will need to validate the source of a input path and load the data:

from urllib.parse import urlparse
import urllib.request

def load_data_from_url(url: str):
    with urllib.request.urlopen(url) as response:
        data = response.read().decode()
    return data


def is_url(input):
    try:
        result = urlparse(input)
        return all([result.scheme, result.netloc])
    except ValueError:
        return False

This method could be useful for managing the Partitura test files, as well as scraping scores from repositories and online sources.

@manoskary manoskary added the enhancement New feature or request label May 13, 2024
@manoskary manoskary self-assigned this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant