{"id":15831668,"url":"https://github.com/cleverdevil/musicbox","last_synced_at":"2025-08-05T11:07:19.066Z","repository":{"id":145921872,"uuid":"587083413","full_name":"cleverdevil/musicbox","owner":"cleverdevil","description":"Software to build an NFC-powered AirPlay music box!","archived":false,"fork":false,"pushed_at":"2023-01-13T23:00:16.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-29T06:17:51.917Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cleverdevil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-09T23:11:56.000Z","updated_at":"2023-07-15T18:05:17.000Z","dependencies_parsed_at":"2023-04-09T19:02:08.712Z","dependency_job_id":null,"html_url":"https://github.com/cleverdevil/musicbox","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"34c1aaccadb9fc6718510e8d981bb9ab97cdffe5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cleverdevil/musicbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmusicbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmusicbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmusicbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmusicbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleverdevil","download_url":"https://codeload.github.com/cleverdevil/musicbox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmusicbox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268883500,"owners_count":24323148,"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","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-05T12:05:58.790Z","updated_at":"2025-08-05T11:07:19.046Z","avatar_url":"https://github.com/cleverdevil.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Musicbox: Raspberry Pi + NFC Digital Jukebox\n\nThis is a very simple personal project that I created for my daughter, provided\nhere as a useful referece for tinkerers that may want to build their own.\nTogether, my daughter and I created a little \"music box\" that she can tap with \nNFC tags that she decorates, and it will stream either a single song or a\nplaylist of songs associated with the tag to her HomePod Mini. She can also tap\na tag to the music box to stop what is currently playing.\n\nThere are two main scripts in this repository, a \"client\" and a \"server.\" The\nclient runs on the music box itself, and the server can run wherever you like,\nprovided that it can be reached via the network by both the client and the\nHomePod target.\n\n## The Music Box itself \n\nFirst, you need a \"client\" device to be the music box. We used a [Raspberry Pi \nZero 2 W](https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/) \nbecause its cheap, powerful, small, and has a large ecosystem. On the Raspberry \nPi, we installed the latest 64-bit release of Raspberry Pi OS.\n\nFor the NFC reader, we went with a [simple USB-powered device from Amazon](\nhttps://www.amazon.com/gp/product/B00GYPIZG6). You can use any USB-powered \nreader with an ACR122 chip. The one we purchased conveniently came with five NFC\ncards.\n\nOn device, we installed Python 3.9, created a virtualenv, and installed the only\ndepdendency for the client - the [PyNFC library](\nhttps://github.com/BarnabyShearer/pynfc). Within the client script, there is a\nvariable `MUSICBOX_SERVER` which must be sets to the URL that refers to the\nserver side of this project.\n\nOnce you're all set, you just run `python musicbox-client.py` and can start\ntapping away. The client sends a maximum of one \"event\" every 10 seconds to\navoid flooding the server. Once tapped, the client just sends a simple HTTP\nrequest to the server with the identifier of the tapped NFC tag. Easy peasy.\n\n## Music Box Server\n\nThe server side does the heavy lift. You could easily run this on the Raspberry\nPi itself, if you don't mind having all of the music on device. I already have a\nlarge music library on my home Synology NAS, so I choose to run the server\nthere.\n\nThe `musicbox-server.py` script is a simple [Flask](\nhttps://flask.palletsprojects.com/) web service, and relies upon the [PyATV \nlibrary](https://pyatv.dev/) to stream music to the HomePod. You'll need to\ninstall both into your Python environment, change the `AIRPLAY_ID` in the script\nto point to the IP of your target HomePod, and then run the service on the port\nof your choosing:\n\n```sh\n$ export FLASK_APP=musicbox-server.py\n$ flask run -h 0.0.0.0 -p 5150\n```\n\nWhen an event is received, the server will look for either a playlist file or a\nMP3 file that maps to the specified tag identifier within a \"music\"\nsubdirectory. For example, if you scan a tag with id `abc123`, then the server\nwill first look for a playlist at `music/abc123.m3u8`, and then an MP3 file at\n`music/abc123.mp3`. If it finds either, it will initiate a stream. If it finds\nnothing, it simply stops whatever is playing.\n\nThat's it! Nothing too fancy. I know this could be made more general purpose,\nbut it works just fine for my needs, and was fun to build with my kiddo. Feel\nfree to fork, borrow, or steal any code within for whatever purpose you like!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleverdevil%2Fmusicbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleverdevil%2Fmusicbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleverdevil%2Fmusicbox/lists"}