Skip to content

Add Pear Desktop (YouTube Music) support #20

Description

@1upbyte

YouTube music could be supported through the Pear Desktop application. It has an API plugin that exposes routes that SyncLyrics could then use to fetch the metadata.

The source code for the API routes are here.

The likely most relevant route would be /api/${API_VERSION}/song-info. I can take a shot at implementing this sometime next week probably too, but it will likely be very vibe-coded (if that's ok, didn't see a contribution guide).

EDIT:

Here is some example output from Dolly Parton's "9 to 5":

{"title":"9 to 5","alternativeTitle":"9 to 5","artist":"Dolly Parton","artistUrl":"https://music.youtube.com/channel/UCXJscayh5BT8m2ZVFQSdeVw","views":47858733,"uploadDate":"2017-01-25T13:52:09-08:00","imageSrc":"https://yt3.googleusercontent.com/6mDY1ncLNzIiWkD-vyaDM1jfcYwx-0kwp1xw3YBEi6k4JuTcMYVKbp6TKZxMwT3YAQ2ZHjZAT36VabPVJw=w544-h544-l90-rj","isPaused":false,"songDuration":181,"elapsedSeconds":97,"url":"https://music.youtube.com/watch?v=E4OzdyxbOuU","videoId":"E4OzdyxbOuU","playlistId":"RDAMVMISqzbbZVIiU","mediaType":"AUDIO","tags":["Dolly Parton","桃麗芭頓","The Essential Dolly Parton","9 to 5"]}

The API returns nothing if the song is paused, so the menu on SyncLyrics could timeout after X seconds/minutes of the API not returning anything.

For authentication, Pear Desktop uses Bearer auth. You first request a token with a POST to /auth/<id> where <id> is any string to identify the client (so maybe SyncLyrics-3ab9ce, with some hex to allow multiple clients). The POST request then returns a JWT token, which can be used with Bearer auth to every subsequent request. Here are curl examples from my machine:

> curl.exe -X POST http://localhost:26538/auth/windows-cli
{"accessToken":"eyJhbGciOiJIUzI1NiIsInR5..."}

> curl.exe http://localhost:26538/api/v1/song-info -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5..."
{"title":"Wanna Be Startin' Somethin'", ...}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions