Skip to content

Commit

Permalink
fixed youtube library loading bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikh Haziq committed Sep 27, 2024
1 parent 0fdec11 commit 775edb0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/app_config.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AppConfig appConfig = AppConfig(version: 27, codeName: '2.0.2');
AppConfig appConfig = AppConfig(version: 28, codeName: '2.0.3');

class AppConfig {
int version;
Expand Down
2 changes: 0 additions & 2 deletions lib/ytmusic/mixins/browsing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ mixin BrowsingMixin on YTMusicServices {
'secondaryContents',
'sectionListRenderer'
]);
// pprint(nav(sectionListRenderer,
// ['contents', 0, 'musicShelfRenderer', 'continuations']));
List? chips =
nav(sectionListRenderer, ['header', 'chipCloudRenderer', 'chips']);
if (chips != null) {
Expand Down
45 changes: 33 additions & 12 deletions lib/ytmusic/mixins/library.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import 'package:gyawun/utils/pprint.dart';

import '../helpers.dart';
import '../yt_service_provider.dart';
import 'utils.dart';

mixin LibraryMixin on YTMusicServices {
Future<Map> getLibrarySongs({String? continuationParams}) async {
Map<String, dynamic> body = {'browseId': 'FEmusic_liked_videos'};

final response = await sendRequest('browse', body,
additionalParams: continuationParams ?? '');

Map outerContents = {};
if (continuationParams != null) {
outerContents =
nav(response, ['continuationContents', 'musicShelfContinuation']);
} else {
outerContents = nav(response, [
Map contents = nav(response, [
'contents',
'singleColumnBrowseResultsRenderer',
'tabs',
Expand All @@ -22,8 +26,13 @@ mixin LibraryMixin on YTMusicServices {
'sectionListRenderer',
'contents',
0,
]);
outerContents = nav(contents, [
'musicShelfRenderer'
])??nav(contents, [
'itemSectionRenderer'
]);

}

String? continuation = nav(outerContents,
Expand All @@ -47,25 +56,27 @@ mixin LibraryMixin on YTMusicServices {
outerContents =
nav(response, ['continuationContents', 'gridContinuation']);
} else {
outerContents = nav(response, [
'contents',
Map contents = nav(response, ['contents',
'singleColumnBrowseResultsRenderer',
'tabs',
0,
'tabRenderer',
'content',
'sectionListRenderer',
'contents',
0,
0,]);
outerContents = nav(contents, [
'gridRenderer',
])??nav(contents, [
'itemSectionRenderer',
]);
}
String? continuation = nav(outerContents,
['continuations', 0, 'nextContinuationData', 'continuation']);
if (continuation != null) {
continuation = getContinuationString(continuation);
}
List contents = nav(outerContents, ['items']);
List contents = nav(outerContents, ['items'])??nav(outerContents, ['contents']);

return {
'contents': handleContents(contents),
Expand All @@ -85,17 +96,19 @@ mixin LibraryMixin on YTMusicServices {
outerContents =
nav(response, ['continuationContents', 'musicShelfContinuation']);
} else {
outerContents = nav(response, [
'contents',
Map contents = nav(response,['contents',
'singleColumnBrowseResultsRenderer',
'tabs',
0,
'tabRenderer',
'content',
'sectionListRenderer',
'contents',
0,
0,]);
outerContents = nav(contents, [
'musicShelfRenderer',
])??nav(contents,[
'itemSectionRenderer',
]);
}
String? continuation = nav(outerContents,
Expand All @@ -120,18 +133,22 @@ mixin LibraryMixin on YTMusicServices {
outerContents =
nav(response, ['continuationContents', 'gridContinuation']);
} else {
outerContents = nav(response, [
'contents',
Map contents = nav(response,[ 'contents',
'singleColumnBrowseResultsRenderer',
'tabs',
0,
'tabRenderer',
'content',
'sectionListRenderer',
'contents',
0,
0,]);
outerContents = nav(contents, [
'gridRenderer'
])??
nav(contents, [
'itemSectionRenderer',
]);

}
String? continuation = nav(outerContents,
['continuations', 0, 'nextContinuationData', 'continuation']);
Expand All @@ -158,7 +175,7 @@ mixin LibraryMixin on YTMusicServices {
outerContents = outerContents =
nav(response, ['continuationContents', 'musicShelfContinuation']);
} else {
outerContents = nav(response, [
Map contents = nav(response,[
'contents',
'singleColumnBrowseResultsRenderer',
'tabs',
Expand All @@ -168,7 +185,11 @@ mixin LibraryMixin on YTMusicServices {
'sectionListRenderer',
'contents',
0,
]);
outerContents = nav(contents, [
'musicShelfRenderer',
])??nav(contents, [
'itemSectionRenderer',
]);
}
String? continuation = nav(outerContents,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: gyawun
description: "A new Flutter project."
publish_to: 'none'
version: 2.0.2+27
version: 2.0.3+28

environment:
sdk: '>=3.4.1 <4.0.0'
Expand Down

0 comments on commit 775edb0

Please sign in to comment.