Skip to content

Commit

Permalink
ythome api fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Apr 13, 2024
1 parent bed8562 commit 3ab2cfa
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 434 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ jobs:
run: jarsigner --verify --verbose build/app/outputs/flutter-apk/app-release.apk

- name: Rename APK file
run: mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/bloomee_tunes_v2.7.1+${{github.run_number}}.apk
run: mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/bloomee_tunes_v2.7.2+${{github.run_number}}.apk

- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: Release
path: |
build/app/outputs/flutter-apk/bloomee_tunes_v2.7.1+${{github.run_number}}.apk
build/app/outputs/flutter-apk/bloomee_tunes_v2.7.2+${{github.run_number}}.apk
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/bloomee_tunes_v2.7.1+${{github.run_number}}.apk"
tag: v2.7.1+${{github.run_number}}
artifacts: "build/app/outputs/flutter-apk/bloomee_tunes_v2.7.2+${{github.run_number}}.apk"
tag: v2.7.2+${{github.run_number}}
token: ${{secrets.SECRET_KEY}}
4 changes: 2 additions & 2 deletions lib/blocs/explore/cubit/explore_cubits.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ class YTMusicCubit extends Cubit<YTMusicCubitState> {
}

void fetchYTMusic() async {
final ytCharts = await YtMusicService().getMusicHome();
final ytCharts = await Isolate.run(() => YtMusicService().getMusicHome());
if (ytCharts.isNotEmpty) {
emit(state.copyWith(ytmData: ytCharts));
final ytChartsJson = jsonEncode(ytCharts);
final ytChartsJson = await compute(jsonEncode, ytCharts);
BloomeeDBService.putAPICache("YTMusic", ytChartsJson);
}
}
Expand Down
30 changes: 18 additions & 12 deletions lib/repository/Youtube/yt_music_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class YtMusicService {
RegExp(r'(\"contents\":{.*?}),\"metadata\"', dotAll: true)
.firstMatch(response.body)![1]!;
final Map data = json.decode('{$searchResults}') as Map;

// dev.log("data: ${json.encode(data)}", name: "YTM");
final List result = data['contents']['twoColumnBrowseResultsRenderer']
['tabs'][0]['tabRenderer']['content']['sectionListRenderer']
['contents'] as List;
Expand All @@ -273,23 +273,29 @@ class YtMusicService {
for (Map element in shelfRenderer) {
String title = element['title']['runs'][0]['text'].trim();

List playlistItems = await formatHomeSections(
element['content']['horizontalListRenderer']['items']);
try {
// dev.log("Inside loop: ${title}", name: "YTM");
List playlistItems = await formatHomeSections(
element['content']['horizontalListRenderer']['items']);

if (playlistItems.isNotEmpty) {
finalResult.add({
'title': title,
'items': playlistItems,
});
} else {
dev.log(
"got null in getMusicHome for '${element['title']['runs'][0]['text']}'",
name: "YTM");
if (playlistItems.isNotEmpty) {
finalResult.add({
'title': title,
'items': playlistItems,
});
} else {
dev.log(
"got null in getMusicHome for '${element['title']['runs'][0]['text']}'",
name: "YTM");
}
} catch (e) {
dev.log("Error inside HomeFormat getMusicHome: $e", name: "YTM");
}
}
// dev.log("finalResult: $finalResult", name: "YTM");

final List finalHeadResult = formatHeadItems(headResult);
// dev.log("finalHeadResult: $finalHeadResult", name: "YTM");
finalResult.removeWhere((element) => element == null);

return {'body': finalResult, 'head': finalHeadResult};
Expand Down
Loading

0 comments on commit 3ab2cfa

Please sign in to comment.