🐛 Bug fixes of querying backend
This commit is contained in:
		| @@ -2,6 +2,8 @@ | ||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||||
| <plist version="1.0"> | ||||
| <dict> | ||||
| 	<key>ITSAppUsesNonExemptEncryption</key> | ||||
| 	<false/> | ||||
| 	<key>CADisableMinimumFrameDurationOnPhone</key> | ||||
| 	<true/> | ||||
| 	<key>CFBundleDevelopmentRegion</key> | ||||
|   | ||||
| @@ -82,7 +82,8 @@ class _PlayerScreenState extends State<PlayerScreen> { | ||||
|                     padding: const EdgeInsets.symmetric(vertical: 24), | ||||
|                     children: [ | ||||
|                       Obx( | ||||
|                         () => LimitedBox( | ||||
|                         () => Center( | ||||
|                           child: LimitedBox( | ||||
|                             maxHeight: maxAlbumSize, | ||||
|                             maxWidth: maxAlbumSize, | ||||
|                             child: Hero( | ||||
| @@ -90,13 +91,15 @@ class _PlayerScreenState extends State<PlayerScreen> { | ||||
|                               child: AspectRatio( | ||||
|                                 aspectRatio: 1, | ||||
|                                 child: ClipRRect( | ||||
|                                 borderRadius: | ||||
|                                     const BorderRadius.all(Radius.circular(16)), | ||||
|                                   borderRadius: const BorderRadius.all( | ||||
|                                     Radius.circular(16), | ||||
|                                   ), | ||||
|                                   child: _albumArt != null | ||||
|                                       ? AutoCacheImage( | ||||
|                                           _albumArt!, | ||||
|                                           width: albumSize, | ||||
|                                           height: albumSize, | ||||
|                                           fit: BoxFit.cover, | ||||
|                                         ) | ||||
|                                       : Container( | ||||
|                                           color: Theme.of(context) | ||||
| @@ -113,6 +116,7 @@ class _PlayerScreenState extends State<PlayerScreen> { | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                       ), | ||||
|                       const Gap(24), | ||||
|                       Obx( | ||||
|                         () => Row( | ||||
|   | ||||
| @@ -167,8 +167,11 @@ class NeteaseSourcedTrack extends SourcedTrack { | ||||
|     final query = SourcedTrack.getSearchTerm(track); | ||||
|  | ||||
|     final client = getClient(); | ||||
|     final resp = | ||||
|         await client.get('/search?keywords=${Uri.encodeComponent(query)}'); | ||||
|     final resp = await client.get( | ||||
|       '/search?keywords=${Uri.encodeComponent(query)}&realIP=${NeteaseSourcedTrack.lookupRealIp()}', | ||||
|     ); | ||||
|     if (resp.body?['code'] == 405) throw TrackNotFoundError(track); | ||||
|     print(resp.body); | ||||
|     final results = resp.body['result']['songs']; | ||||
|  | ||||
|     // We can just trust netease music for now | ||||
| @@ -239,11 +242,10 @@ class NeteaseSourcedTrack extends SourcedTrack { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   static SiblingType toSiblingType(dynamic item) { | ||||
|   static NeteaseSourceInfo toSourceInfo(dynamic item) { | ||||
|     final firstArtist = item['ar'] != null ? item['ar'][0] : item['artists'][0]; | ||||
|  | ||||
|     final SiblingType sibling = ( | ||||
|       info: NeteaseSourceInfo( | ||||
|     return NeteaseSourceInfo( | ||||
|       id: item['id'].toString(), | ||||
|       artist: item['ar'] != null | ||||
|           ? item['ar'].map((x) => x['name']).join(',') | ||||
| @@ -257,7 +259,12 @@ class NeteaseSourcedTrack extends SourcedTrack { | ||||
|           ? Duration(milliseconds: item['dt']) | ||||
|           : Duration(milliseconds: item['duration']), | ||||
|       album: item['al']?['name'], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   static SiblingType toSiblingType(dynamic item) { | ||||
|     final SiblingType sibling = ( | ||||
|       info: toSourceInfo(item), | ||||
|       source: toSourceMap(item), | ||||
|     ); | ||||
|  | ||||
|   | ||||
| @@ -69,6 +69,7 @@ class YoutubeSourcedTrack extends SourcedTrack { | ||||
|               sourceId: siblings.first.info.id, | ||||
|               sourceType: const Value(SourceType.youtube), | ||||
|             ), | ||||
|             mode: InsertMode.insertOrReplace, | ||||
|           ); | ||||
|  | ||||
|       return YoutubeSourcedTrack( | ||||
|   | ||||
| @@ -5,8 +5,10 @@ import 'package:rhythm_box/platform.dart'; | ||||
| class AutoCacheImage extends StatelessWidget { | ||||
|   final String url; | ||||
|   final double? width, height; | ||||
|   final BoxFit? fit; | ||||
|  | ||||
|   const AutoCacheImage(this.url, {super.key, this.width, this.height}); | ||||
|   const AutoCacheImage(this.url, | ||||
|       {super.key, this.width, this.height, this.fit}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| @@ -15,12 +17,14 @@ class AutoCacheImage extends StatelessWidget { | ||||
|         imageUrl: url, | ||||
|         width: width, | ||||
|         height: height, | ||||
|         fit: fit, | ||||
|       ); | ||||
|     } | ||||
|     return Image.network( | ||||
|       url, | ||||
|       width: width, | ||||
|       height: height, | ||||
|       fit: fit, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -116,11 +116,10 @@ class _SiblingTracksState extends State<SiblingTracks> { | ||||
|         ); | ||||
|       } else if (preferences.audioSource == AudioSource.netease) { | ||||
|         final client = NeteaseSourcedTrack.getClient(); | ||||
|         final resp = await client | ||||
|             .get('/search?keywords=${Uri.encodeComponent(searchTerm)}'); | ||||
|         final resp = await client.get( | ||||
|             '/search?keywords=${Uri.encodeComponent(searchTerm)}&realIP=${NeteaseSourcedTrack.lookupRealIp()}'); | ||||
|         final searchResults = resp.body['result']['songs'] | ||||
|             .map(NeteaseSourcedTrack.toSiblingType) | ||||
|             .map((x) => x.info) | ||||
|             .map(NeteaseSourcedTrack.toSourceInfo) | ||||
|             .toList(); | ||||
|  | ||||
|         final activeSourceInfo = (_activeTrack! as SourcedTrack).sourceInfo; | ||||
|   | ||||
| @@ -28,6 +28,8 @@ | ||||
| 	<string>MainMenu</string> | ||||
| 	<key>LSApplicationCategoryType</key> | ||||
| 	<string>public.app-category.music</string> | ||||
| 	<key>ITSAppUsesNonExemptEncryption</key> | ||||
| 	<false/> | ||||
| 	<key>NSPrincipalClass</key> | ||||
| 	<string>NSApplication</string> | ||||
| </dict> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user