mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
chore: remove predownload option
This commit is contained in:
parent
dfea195ec1
commit
b041887402
@ -1,7 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
import 'package:piped_client/piped_client.dart';
|
import 'package:piped_client/piped_client.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
import 'package:spotube/extensions/album_simple.dart';
|
import 'package:spotube/extensions/album_simple.dart';
|
||||||
@ -142,25 +140,6 @@ class SpotubeTrack extends Track {
|
|||||||
final PipedAudioStream ytStream =
|
final PipedAudioStream ytStream =
|
||||||
getStreamInfo(ytVideo, preferences.audioQuality);
|
getStreamInfo(ytVideo, preferences.audioQuality);
|
||||||
|
|
||||||
if (preferences.predownload &&
|
|
||||||
ytVideo.duration < const Duration(minutes: 15)) {
|
|
||||||
await DefaultCacheManager().getFileFromCache(track.id!).then(
|
|
||||||
(file) async {
|
|
||||||
if (file != null) return file.file;
|
|
||||||
|
|
||||||
final res = await get(Uri.parse(ytStream.url));
|
|
||||||
|
|
||||||
final cached = await DefaultCacheManager().putFile(
|
|
||||||
track.id!,
|
|
||||||
res.bodyBytes,
|
|
||||||
fileExtension: ytStream.mimeType.split("/").last,
|
|
||||||
);
|
|
||||||
|
|
||||||
return cached;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SpotubeTrack.fromTrack(
|
return SpotubeTrack.fromTrack(
|
||||||
track: track,
|
track: track,
|
||||||
ytTrack: ytVideo,
|
ytTrack: ytVideo,
|
||||||
@ -193,25 +172,6 @@ class SpotubeTrack extends Track {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.predownload &&
|
|
||||||
video.duration < const Duration(minutes: 15)) {
|
|
||||||
await DefaultCacheManager().getFileFromCache(id!).then(
|
|
||||||
(file) async {
|
|
||||||
if (file != null) return file.file;
|
|
||||||
|
|
||||||
final res = await get(Uri.parse(ytStream.url));
|
|
||||||
|
|
||||||
final cached = await DefaultCacheManager().putFile(
|
|
||||||
id!,
|
|
||||||
res.bodyBytes,
|
|
||||||
fileExtension: ytStream.mimeType.split("/").last,
|
|
||||||
);
|
|
||||||
|
|
||||||
return cached;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SpotubeTrack.fromTrack(
|
return SpotubeTrack.fromTrack(
|
||||||
track: this,
|
track: this,
|
||||||
ytTrack: ytVideo,
|
ytTrack: ytVideo,
|
||||||
|
@ -367,16 +367,6 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SwitchListTile(
|
|
||||||
secondary: const Icon(SpotubeIcons.download),
|
|
||||||
title: Text(context.l10n.pre_download_play),
|
|
||||||
subtitle:
|
|
||||||
Text(context.l10n.pre_download_play_description),
|
|
||||||
value: preferences.predownload,
|
|
||||||
onChanged: (state) {
|
|
||||||
preferences.setPredownload(state);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(SpotubeIcons.playlistRemove),
|
leading: const Icon(SpotubeIcons.playlistRemove),
|
||||||
title: Text(context.l10n.blacklist),
|
title: Text(context.l10n.blacklist),
|
||||||
|
@ -51,8 +51,6 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
|
|
||||||
LayoutMode layoutMode;
|
LayoutMode layoutMode;
|
||||||
|
|
||||||
bool predownload;
|
|
||||||
|
|
||||||
CloseBehavior closeBehavior;
|
CloseBehavior closeBehavior;
|
||||||
|
|
||||||
bool showSystemTrayIcon;
|
bool showSystemTrayIcon;
|
||||||
@ -72,7 +70,6 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
required this.recommendationMarket,
|
required this.recommendationMarket,
|
||||||
required this.themeMode,
|
required this.themeMode,
|
||||||
required this.layoutMode,
|
required this.layoutMode,
|
||||||
required this.predownload,
|
|
||||||
required this.accentColorScheme,
|
required this.accentColorScheme,
|
||||||
this.albumColorSync = true,
|
this.albumColorSync = true,
|
||||||
this.saveTrackLyrics = false,
|
this.saveTrackLyrics = false,
|
||||||
@ -95,12 +92,6 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPredownload(bool value) {
|
|
||||||
predownload = value;
|
|
||||||
notifyListeners();
|
|
||||||
updatePersistence();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setThemeMode(ThemeMode mode) {
|
void setThemeMode(ThemeMode mode) {
|
||||||
themeMode = mode;
|
themeMode = mode;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -231,8 +222,6 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
orElse: () => kIsDesktop ? LayoutMode.extended : LayoutMode.compact,
|
orElse: () => kIsDesktop ? LayoutMode.extended : LayoutMode.compact,
|
||||||
);
|
);
|
||||||
|
|
||||||
predownload = map["predownload"] ?? predownload;
|
|
||||||
|
|
||||||
closeBehavior = map["closeBehavior"] != null
|
closeBehavior = map["closeBehavior"] != null
|
||||||
? CloseBehavior.values[map["closeBehavior"]]
|
? CloseBehavior.values[map["closeBehavior"]]
|
||||||
: closeBehavior;
|
: closeBehavior;
|
||||||
@ -265,7 +254,6 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
"audioQuality": audioQuality.index,
|
"audioQuality": audioQuality.index,
|
||||||
"downloadLocation": downloadLocation,
|
"downloadLocation": downloadLocation,
|
||||||
"layoutMode": layoutMode.name,
|
"layoutMode": layoutMode.name,
|
||||||
"predownload": predownload,
|
|
||||||
"closeBehavior": closeBehavior.index,
|
"closeBehavior": closeBehavior.index,
|
||||||
"showSystemTrayIcon": showSystemTrayIcon,
|
"showSystemTrayIcon": showSystemTrayIcon,
|
||||||
"locale":
|
"locale":
|
||||||
@ -284,6 +272,5 @@ final userPreferencesProvider = ChangeNotifierProvider(
|
|||||||
recommendationMarket: 'US',
|
recommendationMarket: 'US',
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
layoutMode: kIsMobile ? LayoutMode.compact : LayoutMode.adaptive,
|
layoutMode: kIsMobile ? LayoutMode.compact : LayoutMode.adaptive,
|
||||||
predownload: false,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user