Closed yodaluca23 closed 3 months ago
Done, took me a bit. I have a function that uses Foundations XMLParser (Instead of needing to make a new dependency for a specific XML library) to convert any XML to a structured dictionary. If the responses lyricsType is 1 it treats it as non-time synced if it's 3, it treats it as time synced. According to the website 2 is supposed to be just line syned (while three is word synced) but when decoding it base64, its just a bunch of random crap... it must be some other format, I have it just recall the API with lyricsType 1 and treat it as not time synced. Also, you can add the lyricsType form key to the initial POST request to do the song search and get the lyrics in the same request. (which is what I did) I also limited maxCount to 1 so only the first (most likely matched) song is received. Test: API has Word synced (lyricsType: 3): https://open.spotify.com/track/3DamFFqW32WihKkTVlwTYQ API has Line synced (lyricsType: 2, I don't know how to decode this so it fallsback to using lyricsType: 1): https://open.spotify.com/track/2ZrioVBvBpKZXOd8tWcmzR API has plain text lyrics (lyricsType: 1): https://open.spotify.com/track/1uIN3VCVKzMXqF2A2Qlw5q Is not on PetitLyrics (Testing Genius Fallback): https://open.spotify.com/track/6ASIi4DrqR0zH7e4cVm9Ya
Add PetitLyrics as a New Lyrics Source
Description
This pull request introduces a new lyrics source, PetitLyrics. The addition allows users to select PetitLyrics as their preferred lyrics provider, expanding the options available for fetching lyrics. Closes https://github.com/whoeevee/EeveeSpotify/issues/243.
Changes Made
Updated Lyrics Source Section:
EeveeLyricsSettingsView+LyricsSourceSection.swift
to include PetitLyrics in the lyrics source picker.Implemented PetitLyrics Repository:
PetitLyricsRepository.swift
in the/Sources/EeveeSpotify/Lyrics/Repositories
directory.LyricsRepository
protocol for PetitLyrics.Modified Lyrics Fetching Logic:
CustomLyrics.x.swift
andLyricsSource.swift
to handle the new.petitLyrics
case.Affected Files
Sources/EeveeSpotify/Settings/Views/Sections/EeveeLyricsSettingsView+LyricsSourceSection.swift
Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift
Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsSource.swift
Sources/EeveeSpotify/Lyrics/Repositories/PetitLyricsRepository.swift
(new file)Testing
Additional Information
I had to do some hacky things because the search request sends back a full webpage, so it has to scrape it with regex, hopefully, they don't update their site often (by the looks of it they don't). They do apparently have time synced in their app, but I couldn't get it to work with MITMProxy, to see how it's done, I may add it in the future if I can figure it out. Please squash, if/when you merge. Yes this is a PR description template lol.