🐛 Bug fixes of querying backend
This commit is contained in:
		| @@ -1,59 +1,61 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||||||
| <plist version="1.0"> | <plist version="1.0"> | ||||||
| 	<dict> | <dict> | ||||||
| 		<key>CADisableMinimumFrameDurationOnPhone</key> | 	<key>ITSAppUsesNonExemptEncryption</key> | ||||||
| 		<true/> | 	<false/> | ||||||
| 		<key>CFBundleDevelopmentRegion</key> | 	<key>CADisableMinimumFrameDurationOnPhone</key> | ||||||
| 		<string>$(DEVELOPMENT_LANGUAGE)</string> | 	<true/> | ||||||
| 		<key>CFBundleDisplayName</key> | 	<key>CFBundleDevelopmentRegion</key> | ||||||
| 		<string>Groovy Box</string> | 	<string>$(DEVELOPMENT_LANGUAGE)</string> | ||||||
| 		<key>CFBundleExecutable</key> | 	<key>CFBundleDisplayName</key> | ||||||
| 		<string>$(EXECUTABLE_NAME)</string> | 	<string>Groovy Box</string> | ||||||
| 		<key>CFBundleIdentifier</key> | 	<key>CFBundleExecutable</key> | ||||||
| 		<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | 	<string>$(EXECUTABLE_NAME)</string> | ||||||
| 		<key>CFBundleInfoDictionaryVersion</key> | 	<key>CFBundleIdentifier</key> | ||||||
| 		<string>6.0</string> | 	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||||||
| 		<key>CFBundleName</key> | 	<key>CFBundleInfoDictionaryVersion</key> | ||||||
| 		<string>Groovy Box</string> | 	<string>6.0</string> | ||||||
| 		<key>CFBundlePackageType</key> | 	<key>CFBundleName</key> | ||||||
| 		<string>APPL</string> | 	<string>Groovy Box</string> | ||||||
| 		<key>CFBundleShortVersionString</key> | 	<key>CFBundlePackageType</key> | ||||||
| 		<string>$(FLUTTER_BUILD_NAME)</string> | 	<string>APPL</string> | ||||||
| 		<key>CFBundleSignature</key> | 	<key>CFBundleShortVersionString</key> | ||||||
| 		<string>????</string> | 	<string>$(FLUTTER_BUILD_NAME)</string> | ||||||
| 		<key>CFBundleVersion</key> | 	<key>CFBundleSignature</key> | ||||||
| 		<string>$(FLUTTER_BUILD_NUMBER)</string> | 	<string>????</string> | ||||||
| 		<key>LSApplicationCategoryType</key> | 	<key>CFBundleVersion</key> | ||||||
| 		<string>public.app-category.music</string> | 	<string>$(FLUTTER_BUILD_NUMBER)</string> | ||||||
| 		<key>LSRequiresIPhoneOS</key> | 	<key>LSApplicationCategoryType</key> | ||||||
| 		<true/> | 	<string>public.app-category.music</string> | ||||||
| 		<key>NSMicrophoneUsageDescription</key> | 	<key>LSRequiresIPhoneOS</key> | ||||||
| 		<string>To provide information for RhythmBox to normalize the output audio</string> | 	<true/> | ||||||
| 		<key>UIApplicationSupportsIndirectInputEvents</key> | 	<key>NSMicrophoneUsageDescription</key> | ||||||
| 		<true/> | 	<string>To provide information for RhythmBox to normalize the output audio</string> | ||||||
| 		<key>UIBackgroundModes</key> | 	<key>UIApplicationSupportsIndirectInputEvents</key> | ||||||
| 		<array> | 	<true/> | ||||||
| 			<string>audio</string> | 	<key>UIBackgroundModes</key> | ||||||
| 		</array> | 	<array> | ||||||
| 		<key>UILaunchStoryboardName</key> | 		<string>audio</string> | ||||||
| 		<string>LaunchScreen</string> | 	</array> | ||||||
| 		<key>UIMainStoryboardFile</key> | 	<key>UILaunchStoryboardName</key> | ||||||
| 		<string>Main</string> | 	<string>LaunchScreen</string> | ||||||
| 		<key>UIStatusBarHidden</key> | 	<key>UIMainStoryboardFile</key> | ||||||
| 		<false/> | 	<string>Main</string> | ||||||
| 		<key>UISupportedInterfaceOrientations</key> | 	<key>UIStatusBarHidden</key> | ||||||
| 		<array> | 	<false/> | ||||||
| 			<string>UIInterfaceOrientationPortrait</string> | 	<key>UISupportedInterfaceOrientations</key> | ||||||
| 			<string>UIInterfaceOrientationLandscapeLeft</string> | 	<array> | ||||||
| 			<string>UIInterfaceOrientationLandscapeRight</string> | 		<string>UIInterfaceOrientationPortrait</string> | ||||||
| 		</array> | 		<string>UIInterfaceOrientationLandscapeLeft</string> | ||||||
| 		<key>UISupportedInterfaceOrientations~ipad</key> | 		<string>UIInterfaceOrientationLandscapeRight</string> | ||||||
| 		<array> | 	</array> | ||||||
| 			<string>UIInterfaceOrientationPortrait</string> | 	<key>UISupportedInterfaceOrientations~ipad</key> | ||||||
| 			<string>UIInterfaceOrientationPortraitUpsideDown</string> | 	<array> | ||||||
| 			<string>UIInterfaceOrientationLandscapeLeft</string> | 		<string>UIInterfaceOrientationPortrait</string> | ||||||
| 			<string>UIInterfaceOrientationLandscapeRight</string> | 		<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||||||
| 		</array> | 		<string>UIInterfaceOrientationLandscapeLeft</string> | ||||||
| 	</dict> | 		<string>UIInterfaceOrientationLandscapeRight</string> | ||||||
|  | 	</array> | ||||||
|  | </dict> | ||||||
| </plist> | </plist> | ||||||
|   | |||||||
| @@ -82,34 +82,38 @@ class _PlayerScreenState extends State<PlayerScreen> { | |||||||
|                     padding: const EdgeInsets.symmetric(vertical: 24), |                     padding: const EdgeInsets.symmetric(vertical: 24), | ||||||
|                     children: [ |                     children: [ | ||||||
|                       Obx( |                       Obx( | ||||||
|                         () => LimitedBox( |                         () => Center( | ||||||
|                           maxHeight: maxAlbumSize, |                           child: LimitedBox( | ||||||
|                           maxWidth: maxAlbumSize, |                             maxHeight: maxAlbumSize, | ||||||
|                           child: Hero( |                             maxWidth: maxAlbumSize, | ||||||
|                             tag: const Key('current-active-track-album-art'), |                             child: Hero( | ||||||
|                             child: AspectRatio( |                               tag: const Key('current-active-track-album-art'), | ||||||
|                               aspectRatio: 1, |                               child: AspectRatio( | ||||||
|                               child: ClipRRect( |                                 aspectRatio: 1, | ||||||
|                                 borderRadius: |                                 child: ClipRRect( | ||||||
|                                     const BorderRadius.all(Radius.circular(16)), |                                   borderRadius: const BorderRadius.all( | ||||||
|                                 child: _albumArt != null |                                     Radius.circular(16), | ||||||
|                                     ? AutoCacheImage( |                                   ), | ||||||
|                                         _albumArt!, |                                   child: _albumArt != null | ||||||
|                                         width: albumSize, |                                       ? AutoCacheImage( | ||||||
|                                         height: albumSize, |                                           _albumArt!, | ||||||
|                                       ) |                                           width: albumSize, | ||||||
|                                     : Container( |                                           height: albumSize, | ||||||
|                                         color: Theme.of(context) |                                           fit: BoxFit.cover, | ||||||
|                                             .colorScheme |                                         ) | ||||||
|                                             .surfaceContainerHigh, |                                       : Container( | ||||||
|                                         width: 64, |                                           color: Theme.of(context) | ||||||
|                                         height: 64, |                                               .colorScheme | ||||||
|                                         child: const Center( |                                               .surfaceContainerHigh, | ||||||
|                                           child: Icon(Icons.image), |                                           width: 64, | ||||||
|  |                                           height: 64, | ||||||
|  |                                           child: const Center( | ||||||
|  |                                             child: Icon(Icons.image), | ||||||
|  |                                           ), | ||||||
|                                         ), |                                         ), | ||||||
|                                       ), |                                 ), | ||||||
|                               ), |                               ).marginSymmetric(horizontal: 24), | ||||||
|                             ).marginSymmetric(horizontal: 24), |                             ), | ||||||
|                           ), |                           ), | ||||||
|                         ), |                         ), | ||||||
|                       ), |                       ), | ||||||
|   | |||||||
| @@ -167,8 +167,11 @@ class NeteaseSourcedTrack extends SourcedTrack { | |||||||
|     final query = SourcedTrack.getSearchTerm(track); |     final query = SourcedTrack.getSearchTerm(track); | ||||||
|  |  | ||||||
|     final client = getClient(); |     final client = getClient(); | ||||||
|     final resp = |     final resp = await client.get( | ||||||
|         await client.get('/search?keywords=${Uri.encodeComponent(query)}'); |       '/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']; |     final results = resp.body['result']['songs']; | ||||||
|  |  | ||||||
|     // We can just trust netease music for now |     // We can just trust netease music for now | ||||||
| @@ -239,25 +242,29 @@ 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 firstArtist = item['ar'] != null ? item['ar'][0] : item['artists'][0]; | ||||||
|  |  | ||||||
|  |     return NeteaseSourceInfo( | ||||||
|  |       id: item['id'].toString(), | ||||||
|  |       artist: item['ar'] != null | ||||||
|  |           ? item['ar'].map((x) => x['name']).join(',') | ||||||
|  |           : item['artists'].map((x) => x['name']).toString(), | ||||||
|  |       artistUrl: 'https://music.163.com/#/artist?id=${firstArtist['id']}', | ||||||
|  |       pageUrl: 'https://music.163.com/#/song?id=${item['id']}', | ||||||
|  |       thumbnail: item['al']?['picUrl'] ?? | ||||||
|  |           'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg', | ||||||
|  |       title: item['name'], | ||||||
|  |       duration: item['dt'] != null | ||||||
|  |           ? Duration(milliseconds: item['dt']) | ||||||
|  |           : Duration(milliseconds: item['duration']), | ||||||
|  |       album: item['al']?['name'], | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   static SiblingType toSiblingType(dynamic item) { | ||||||
|     final SiblingType sibling = ( |     final SiblingType sibling = ( | ||||||
|       info: NeteaseSourceInfo( |       info: toSourceInfo(item), | ||||||
|         id: item['id'].toString(), |  | ||||||
|         artist: item['ar'] != null |  | ||||||
|             ? item['ar'].map((x) => x['name']).join(',') |  | ||||||
|             : item['artists'].map((x) => x['name']).toString(), |  | ||||||
|         artistUrl: 'https://music.163.com/#/artist?id=${firstArtist['id']}', |  | ||||||
|         pageUrl: 'https://music.163.com/#/song?id=${item['id']}', |  | ||||||
|         thumbnail: item['al']?['picUrl'] ?? |  | ||||||
|             'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg', |  | ||||||
|         title: item['name'], |  | ||||||
|         duration: item['dt'] != null |  | ||||||
|             ? Duration(milliseconds: item['dt']) |  | ||||||
|             : Duration(milliseconds: item['duration']), |  | ||||||
|         album: item['al']?['name'], |  | ||||||
|       ), |  | ||||||
|       source: toSourceMap(item), |       source: toSourceMap(item), | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -69,6 +69,7 @@ class YoutubeSourcedTrack extends SourcedTrack { | |||||||
|               sourceId: siblings.first.info.id, |               sourceId: siblings.first.info.id, | ||||||
|               sourceType: const Value(SourceType.youtube), |               sourceType: const Value(SourceType.youtube), | ||||||
|             ), |             ), | ||||||
|  |             mode: InsertMode.insertOrReplace, | ||||||
|           ); |           ); | ||||||
|  |  | ||||||
|       return YoutubeSourcedTrack( |       return YoutubeSourcedTrack( | ||||||
|   | |||||||
| @@ -5,8 +5,10 @@ import 'package:rhythm_box/platform.dart'; | |||||||
| class AutoCacheImage extends StatelessWidget { | class AutoCacheImage extends StatelessWidget { | ||||||
|   final String url; |   final String url; | ||||||
|   final double? width, height; |   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 |   @override | ||||||
|   Widget build(BuildContext context) { |   Widget build(BuildContext context) { | ||||||
| @@ -15,12 +17,14 @@ class AutoCacheImage extends StatelessWidget { | |||||||
|         imageUrl: url, |         imageUrl: url, | ||||||
|         width: width, |         width: width, | ||||||
|         height: height, |         height: height, | ||||||
|  |         fit: fit, | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|     return Image.network( |     return Image.network( | ||||||
|       url, |       url, | ||||||
|       width: width, |       width: width, | ||||||
|       height: height, |       height: height, | ||||||
|  |       fit: fit, | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -116,11 +116,10 @@ class _SiblingTracksState extends State<SiblingTracks> { | |||||||
|         ); |         ); | ||||||
|       } else if (preferences.audioSource == AudioSource.netease) { |       } else if (preferences.audioSource == AudioSource.netease) { | ||||||
|         final client = NeteaseSourcedTrack.getClient(); |         final client = NeteaseSourcedTrack.getClient(); | ||||||
|         final resp = await client |         final resp = await client.get( | ||||||
|             .get('/search?keywords=${Uri.encodeComponent(searchTerm)}'); |             '/search?keywords=${Uri.encodeComponent(searchTerm)}&realIP=${NeteaseSourcedTrack.lookupRealIp()}'); | ||||||
|         final searchResults = resp.body['result']['songs'] |         final searchResults = resp.body['result']['songs'] | ||||||
|             .map(NeteaseSourcedTrack.toSiblingType) |             .map(NeteaseSourcedTrack.toSourceInfo) | ||||||
|             .map((x) => x.info) |  | ||||||
|             .toList(); |             .toList(); | ||||||
|  |  | ||||||
|         final activeSourceInfo = (_activeTrack! as SourcedTrack).sourceInfo; |         final activeSourceInfo = (_activeTrack! as SourcedTrack).sourceInfo; | ||||||
|   | |||||||
| @@ -28,6 +28,8 @@ | |||||||
| 	<string>MainMenu</string> | 	<string>MainMenu</string> | ||||||
| 	<key>LSApplicationCategoryType</key> | 	<key>LSApplicationCategoryType</key> | ||||||
| 	<string>public.app-category.music</string> | 	<string>public.app-category.music</string> | ||||||
|  | 	<key>ITSAppUsesNonExemptEncryption</key> | ||||||
|  | 	<false/> | ||||||
| 	<key>NSPrincipalClass</key> | 	<key>NSPrincipalClass</key> | ||||||
| 	<string>NSApplication</string> | 	<string>NSApplication</string> | ||||||
| </dict> | </dict> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user