{"id":20238025,"url":"https://github.com/basilfx/flask-daapserver","last_synced_at":"2025-04-10T19:12:57.156Z","repository":{"id":16995707,"uuid":"19758799","full_name":"basilfx/flask-daapserver","owner":"basilfx","description":"DAAP server for streaming media, built around the Flask micro framework.","archived":false,"fork":false,"pushed_at":"2018-03-14T07:03:54.000Z","size":209,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T16:55:10.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/basilfx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-13T22:58:07.000Z","updated_at":"2023-04-02T22:57:44.000Z","dependencies_parsed_at":"2022-07-26T11:32:08.536Z","dependency_job_id":null,"html_url":"https://github.com/basilfx/flask-daapserver","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basilfx%2Fflask-daapserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basilfx%2Fflask-daapserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basilfx%2Fflask-daapserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basilfx%2Fflask-daapserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basilfx","download_url":"https://codeload.github.com/basilfx/flask-daapserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248252665,"owners_count":21072699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T08:30:20.400Z","updated_at":"2025-04-10T19:12:57.132Z","avatar_url":"https://github.com/basilfx.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-DAAPServer\nDAAP server for streaming media, built around the Flask micro framework. Supports iTunes, artwork and revisioning.\n\n[![Build Status](https://travis-ci.org/basilfx/flask-daapserver.svg?branch=master)](https://travis-ci.org/basilfx/flask-daapserver)\n[![Latest Version](https://img.shields.io/pypi/v/flask-daapserver.svg)](https://pypi.python.org/pypi/flask-daapserver/)\n\n## Introduction.\nThe Digital Audio Access Protocol (DAAP) is a protocol designed by Apple to share media over the network, using HTTP as transport layer. It advertises itself via Bonjour/Zeroconf.\n\nThis Python module implements the full stack, providing a HTTP server (built around Flask), a high-level application layer and Bonjour/Zeroconf advertising.\n\n## Data model\nThe DAAP data model consists of the following entities:\n\n* Server\n* Databases\n* Containers\n* Items\n* Container Items\n\nThere are a few more, but the above ones have been implemented.\n\nA server contains databases, a database contains containers and items, a container contains container items and a container item is a one-to-many mapping between items and containers. While the DAAP client implementation of iTunes only supports one database per server (this is the one that shows up in iTunes), the models does not impose any restrictions. Therefore, this implementation does not keep you from adding multiple databases to a server.\n\nThe DAAP protocol efficiently updates the entities. Only deltas are send to the client. For this to work, the server has to add revision (version) numbers to the entities, and map entities to revisions. Because several clients can be on different revisions, it is necessary to keep track of all revisions. When all clients are up to date, the older revisions can be cleaned.\n\nThe DAAP protocol assumes that string are encoded as UTF-8. Therefore, you are encouraged to use unicode objects where possible.\n\n### Mutable versus immutable\nPython is a language that does not implement access modifiers (private/protected/public). Therefore, an instance variable can be changed, no matter from where. This makes it harder to implement immutable types. Cython (which converts Python to C), allows you to add these modifiers, in some sense.\n\nSupport for immutable types was planned, but dropped for the following reasons:\n\n* Creating (copy of) objects is expensive, and there are many objects.\n* Cython objects ([Extension Types](http://docs.cython.org/src/userguide/extension_types.html)) should be subclassable in Python, which poses problems with modifiers.\n* The DAAP protocol does not care about the object contents. For instance, if `obj_in_v3 is obj_in_v4`, and you change `obj_in_v4.name`, any client that still has to update to revision 3 will receive the change made in revision 4. This isn't a problem if you want to update clients to the latest version.\n\nDo note that this module does not merge objects with the same ID of different revisions. For instance, the following will fail:\n\n```python\ndb_rev1 = Database(id=1, name=\"My DB\")\nserver.databases.add(db_rev1)\nserver.databases[1] is db_rev1  # Is True\n\ndb_rev1.items.add(Item(id=1, name=\"Song 1\"))\ndb_rev1.items.add(Item(id=2, name=\"Song 2\"))\ndb_rev1.items.add(Item(id=3, name=\"Song 3\"))\n\ndb_rev2 = Database(id=2, name=\"My Updated DB\")\nserver.databases.add(db_rev2)\nserver.databases[1] is db_rev2  # Is True\n\nlen(db_rev1.items) is not len(db_rev2.items)  # Reference to items lost because\n                                              # db_rev1.items was overwritten.\n```\n\nIf you want immutability, a correct way is the following:\n\n```python\ndb_rev2 = copy.copy(server.databases[1])\ndb_rev2.name = \"My DB, version 2\"\n\ndb_rev1.items is db_rev2.items  # Is True\n```\n\nThe copy can even be skipped if you don't care about actual immutability and don't mind that intermediate revision will all be the same:\n\n```python\ndb_rev3 = server.databases[1]\ndb_rev3.name = \"My DB, version 3\"\n\ndb_rev1.items is db_rev2.items is db_rev3.items  # Is True\ndb_rev2.name == db_rev3.name  # Is True because db_rev3 is not a copy. However,\n                              # the revisioning store will detect this as\n                              # another update.\n```\n\n## Installation\nMake sure Cython is installed. It is required to boost performance of some modules significantly.\n\nTo install, simply run `pip install flask-daapserver`. It should install all dependencies and compile the Cython-based modules. If you want the latest version, type `pip install git+https://github.com/basilfx/flask-daapserver`.\n\n### Upgrade notice\nThe revisioning storage API has changed between version v2.3.0 and v3.0.0. Due to the large overhead of revisioning, it was decided that there should be less memory usage and faster access. While the API has remained similar, a few changes have been made:\n\n* Cython is required now.\n* The global object store has been removed. Every container now has its own store for its children. Therefore, it is very important to add objects in the right order. For instance, do not add a item to a database before adding the database to the server (the models do not offer advanced ORM functionality).\n* The previous version fixed compatibility with iTunes 12.1. For some reason, iTunes expected the first revision to be two. The fix simply included to start revisions from 2. This version removed this 'workaround', and now expects the first revision to be committed first, e.g. setting up the initial structure first. See the examples for more information.\n* Auto-commit of changed has been removed. The user should commit manually. The `daapserver.models.BaseServer` has a `commit` method that will propagate the commit to all attached databases, containers and so forth.\n* The `added()` and `edited()` methods on `daapserver.models.Collection` have been replaced by `updated()`. The DAAP protocol does not differ between both.\n\nTo give an idea of the performance impact, the `utils/benchmark.py` script yielded an improvement of 108MB vs 196MB in memory usage and 0.8375s vs 4.3017s in time (100,000 items, Python 2.7.9, OS X 10.10, 64 Bits).\n\n## Running tests\nThere are several unit tests included to test core components. The test suite can be invoked using `python setup.py nosetests`.\n\n## Usage\nTake a look at the examples, or to the projects using Flask-DAAPServer:\n\n* [SubDaap](https://github.com/basilfx/SubDaap) \u0026mdash; Bridge between SubSonic and iTunes.\n\n## Examples\nThere are four examples included in the `examples/` directory. You can run them with `python examples/\u003cfilename\u003e`. Check the source for more information and the details.\n\n* `ExampleServer.py` \u0026mdash; Most basic example of a DAAP server.\n* `RevisionServer.py` \u0026mdash; Demonstration of revisioning capabilities.\n* `SoundcloudServer.py` \u0026mdash; Soundcloud server that streams all tracks of a certain users. Requires a Client ID and the Soundcloud Python module.\n\n## Contributing\nFeel free to submit a pull request. All pull requests must be made against the `development` branch. Python code should follow the PEP-8 conventions and tested (if applicable).\n\n## License\nSee the `LICENSE` file (MIT license).\n\nPart of this work (DAAP object encoding) is based on the original work of Davyd Madeley.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasilfx%2Fflask-daapserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasilfx%2Fflask-daapserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasilfx%2Fflask-daapserver/lists"}