🎨 Prefer single quote

This commit is contained in:
2024-08-27 14:48:31 +08:00
parent e7ea852725
commit 95b04adede
31 changed files with 470 additions and 630 deletions

View File

@ -17,29 +17,29 @@ abstract class SongLinkService {
try {
final client = GetConnect();
final res = await client.get(
"https://song.link/s/$spotifyId",
'https://song.link/s/$spotifyId',
headers: {
"Accept":
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
},
);
final document = parse(res.body);
final script = document.getElementById("__NEXT_DATA__")?.text;
final script = document.getElementById('__NEXT_DATA__')?.text;
if (script == null) {
return <SongLink>[];
}
final pageProps = jsonDecode(script) as Map<String, dynamic>;
final songLinks = pageProps["props"]?["pageProps"]?["pageData"]
?["sections"]
final songLinks = pageProps['props']?['pageProps']?['pageData']
?['sections']
?.firstWhere(
(section) => section?["sectionId"] == "section|auto|links|listen",
)?["links"] as List?;
(section) => section?['sectionId'] == 'section|auto|links|listen',
)?['links'] as List?;
return songLinks?.map((link) => SongLink.fromJson(link)).toList() ??
<SongLink>[];