{"id":18550956,"url":"https://github.com/mikescops/upnp-client-ts","last_synced_at":"2025-04-09T22:31:24.864Z","repository":{"id":65593778,"uuid":"591747130","full_name":"Mikescops/upnp-client-ts","owner":"Mikescops","description":"🎧 A NodeJS UPNP Client and MediaRenderer written in Typescript","archived":false,"fork":false,"pushed_at":"2023-12-28T16:17:31.000Z","size":557,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T12:47:39.431Z","etag":null,"topics":["client","device","dlna","media","renderer","upnp"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/upnp-client-ts","language":"TypeScript","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/Mikescops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["mikescops"]}},"created_at":"2023-01-21T18:31:14.000Z","updated_at":"2025-02-16T14:53:45.000Z","dependencies_parsed_at":"2023-02-15T17:30:47.460Z","dependency_job_id":null,"html_url":"https://github.com/Mikescops/upnp-client-ts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mikescops%2Fupnp-client-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mikescops%2Fupnp-client-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mikescops%2Fupnp-client-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mikescops%2Fupnp-client-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mikescops","download_url":"https://codeload.github.com/Mikescops/upnp-client-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248123539,"owners_count":21051489,"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":["client","device","dlna","media","renderer","upnp"],"created_at":"2024-11-06T21:06:27.389Z","updated_at":"2025-04-09T22:31:24.529Z","avatar_url":"https://github.com/Mikescops.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mikescops"],"categories":[],"sub_categories":[],"readme":"# UPNP Client and MediaRenderer for NodeJS\n\n![GitHub package.json version](https://img.shields.io/github/package-json/v/mikescops/upnp-client-ts)\n![npm](https://img.shields.io/npm/v/upnp-client-ts)\n![npm](https://img.shields.io/npm/dw/upnp-client-ts)\n![GitHub](https://img.shields.io/github/license/mikescops/upnp-client-ts)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mikescops/upnp-client-ts/pr-validation.yml)\n\nA modern UPNP client made in Typescript. Compatible with both ESM and CommonJS.\n\n-   UpnpDeviceClient: to connect to any UPNP devices\n-   UpnpMediaRendererClient: to play medias on UPNP devices\n-   also includes DLNA helpers\n\n## Install\n\n```bash\n$ npm install upnp-client-ts\n```\n\n## Usage of UpnpDeviceClient\n\n```ts\nimport upnp from 'upnp-client';\n\n// Instantiate a client with a device description URL (discovered by SSDP)\nconst client = new upnp.UpnpDeviceClient('http://192.168.1.50:4873/foo.xml');\n\n// Get the device description\nconst deviceDescription = await client.getDeviceDescription();\nconsole.log(deviceDescription);\n\n// Get the device's AVTransport service description\nconst serviceDescription = await client.getServiceDescription('AVTransport');\nconsole.log(serviceDescription);\n\n// Call GetMediaInfo on the AVTransport service\nconst callActionResponse = await client.callAction('AVTransport', 'GetMediaInfo', { InstanceID: 0 });\nconsole.log(callActionResponse);\n\nconst listener = (event: UpnpEvent) =\u003e {\n    console.log(event);\n};\n\nawait client.subscribe('AVTransport', listener);\n// Will receive events like { InstanceID: 0, TransportState: 'PLAYING' } when playing media\n\nawait client.unsubscribe('AVTransport', listener);\n```\n\n## Usage of UpnpMediaRendererClient\n\n```ts\nimport upnp from 'upnp-client';\n\nconst client = new upnp.UpnpMediaRendererClient('http://192.168.1.50:54380/MediaRenderer_HT-A9.xml');\n\nconst options = {\n    autoplay: true,\n    contentType: 'audio/flac',\n    dlnaFeatures: dlnaContentFeatures, // see below for dlnaHelpers\n    metadata: {\n        title: 'My song',\n        creator: 'My creator',\n        artist: 'My artist',\n        album: 'My album',\n        albumArtURI: 'http://127.0.0.1/albumArtURI.jpg',\n        type: 'audio'\n    }\n};\n\nawait client.load('http://127.0.0.1/music.flac', options);\n\nawait client.loadNext('http://127.0.0.1/next-music.flac', options);\n\nawait client.pause();\n\nawait client.play();\n\nawait client.stop();\n\nawait client.next();\n\nawait client.previous();\n\nawait client.seek(60);\n\n// you can also call any AVTransport action supported by your device\nconst response = await client.callAVTransport('YourCustomAVTransportCall', {\n    InstanceID: client.instanceId\n});\n```\n\n## Usage of dlnaHelpers\n\nYou can generate DLNA flags and features thanks to the provided helpers, for instance:\n\n```ts\nconst dlnaContentFeatures =\n    `${upnp.dlnaHelpers.getDlnaSeekModeFeature('range')};` +\n    `${upnp.dlnaHelpers.getDlnaTranscodeFeature(false)};` +\n    `${upnp.dlnaHelpers.defaultFlags.DLNA_STREAMING_TIME_BASED_FLAGS}`;\n```\n\n## Tips and tricks\n\nIn the metadata you're passing to your speaker, make sure to avoid using accents and special characters.\n\nHere is a simple helper you could use:\n\n```ts\nconst escapeSpecialChars = (value: string) =\u003e {\n    return value\n        .normalize('NFD')\n        .replace(/[\\u0300-\\u036f]/g, '') // remove all accents from characters\n        .replace(/\u0026/g, '\u0026amp;')\n        .replace(/\u003c/g, '\u0026lt;')\n        .replace(/\u003e/g, '\u0026gt;')\n        .replace(/’/g, \"'\");\n};\n```\n\n## Debugging\n\nRun with debug traces\n\n```sh\n$ DEBUG=true node index.js\n```\n\n## Inspiration\n\nThis project is based on the [awesome work from @thibauts](https://github.com/thibauts/node-upnp-device-client).\n\n## Maintainer\n\n| [![twitter/mikescops](https://avatars0.githubusercontent.com/u/4266283?s=100\u0026v=4)](https://pixelswap.fr 'Personal Website') |\n| --------------------------------------------------------------------------------------------------------------------------- |\n| [Corentin Mors](https://pixelswap.fr/)                                                                                      |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikescops%2Fupnp-client-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikescops%2Fupnp-client-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikescops%2Fupnp-client-ts/lists"}