Skip to content

Commit

Permalink
yt api fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Mar 24, 2024
1 parent 4842411 commit 74e7408
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
2 changes: 0 additions & 2 deletions lib/blocs/settings_cubit/cubit/settings_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:Bloomee/routes_and_consts/global_str_consts.dart';
import 'package:Bloomee/services/db/bloomee_db_service.dart';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';

part 'settings_state.dart';

class SettingsCubit extends Cubit<SettingsState> {
Expand Down
20 changes: 9 additions & 11 deletions lib/repository/Youtube/youtube_api.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';

import 'package:Bloomee/services/db/bloomee_db_service.dart';
import 'package:html_unescape/html_unescape_small.dart';
import 'package:http/http.dart';
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
Expand Down Expand Up @@ -47,13 +47,11 @@ class YouTubeServices {
}
final Map? response = await formatVideo(
video: vid,
// quality: Hive.box('settings')
// .get(
// 'ytQuality',
// defaultValue: 'Low',
// )
// .toString(),
quality: 'Low',
quality: await BloomeeDBService.getSettingStr(
'ytQuality',
defaultValue: 'Low',
) ??
'Low',
data: data,
getUrl: getUrl ?? true,
// preferM4a: Hive.box(
Expand All @@ -72,9 +70,9 @@ class YouTubeServices {
}
String quality;
try {
// quality =
// Hive.box('settings').get('quality', defaultValue: 'Low').toString();
quality = 'Low';
quality = await BloomeeDBService.getSettingStr('quality',
defaultValue: 'Low') ??
'Low';
} catch (e) {
quality = 'Low';
}
Expand Down
19 changes: 0 additions & 19 deletions lib/repository/Youtube/ytmusic/nav.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/*
* This file is part of BlackHole (https://github.com/Sangwan5688/BlackHole).
*
* BlackHole is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BlackHole is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with BlackHole. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (c) 2021-2023, Ankit Sangwan
const */

const content = ['contents', 0];
const runText = ['runs', 0, 'text'];
const tabContent = ['tabs', 0, 'tabRenderer', 'content'];
Expand Down
9 changes: 9 additions & 0 deletions lib/screens/widgets/carousal_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:Bloomee/blocs/explore/cubit/explore_cubits.dart';
import 'package:Bloomee/blocs/settings_cubit/cubit/settings_cubit.dart';
import 'package:Bloomee/screens/screen/chart/chart_widget.dart';
import 'package:Bloomee/screens/screen/chart/show_charts.dart';
import 'package:Bloomee/services/db/bloomee_db_service.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -28,11 +29,19 @@ class _CaraouselWidgetState extends State<CaraouselWidget> {
List<ChartCubit> chartCubitList = List.empty(growable: true);
bool autoSlideCharts = true;

Future<void> initSettings() async {
autoSlideCharts = await BloomeeDBService.getSettingBool(
GlobalStrConsts.autoSlideCharts) ??
true;
setState(() {});
}

@override
void initState() {
for (var i in chartInfoList) {
chartCubitList.add(ChartCubit(i, fetchChartCubit));
}
initSettings();
super.initState();
context.read<SettingsCubit>().stream.listen((event) {
if (autoSlideCharts != event.autoSlideCharts) {
Expand Down
25 changes: 21 additions & 4 deletions lib/services/db/bloomee_db_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,39 @@ class BloomeeDBService {
}
}

static Future<String?> getSettingStr(String key) async {
static Future<String?> getSettingStr(String key,
{String? defaultValue}) async {
Isar isarDB = await db;
return isarDB.appSettingsStrDBs
final settingValue = isarDB.appSettingsStrDBs
.filter()
.settingNameEqualTo(key)
.findFirstSync()
?.settingValue;
if (settingValue != null) {
return settingValue;
} else {
// if (defaultValue != null) {
// putSettingStr(key, defaultValue);
// }
return defaultValue;
}
}

static Future<bool?> getSettingBool(String key) async {
static Future<bool?> getSettingBool(String key, {bool? defaultValue}) async {
Isar isarDB = await db;
return isarDB.appSettingsBoolDBs
final settingValue = isarDB.appSettingsBoolDBs
.filter()
.settingNameEqualTo(key)
.findFirstSync()
?.settingValue;
if (settingValue != null) {
return settingValue;
} else {
// if (defaultValue != null) {
// putSettingBool(key, defaultValue);
// }
return defaultValue;
}
}

static Future<Stream<AppSettingsStrDB?>?> getWatcher4SettingStr(
Expand Down

0 comments on commit 74e7408

Please sign in to comment.