mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00

* Added a new setting that customizes the file name format of downloaded songs. The two options are "Title - Artists" or "Artists - Title". The default option is "Title - Artists", which matches the current implementation. * Updated the way existing songs are searched for in the song downloads folder. Instead of searching by name, song metadata is checked.
162 lines
5.4 KiB
Dart
162 lines
5.4 KiB
Dart
part of '../database.dart';
|
|
|
|
enum LayoutMode {
|
|
compact,
|
|
extended,
|
|
adaptive,
|
|
}
|
|
|
|
enum FileNameFormat {
|
|
titleArtists,
|
|
artistsTitle,
|
|
}
|
|
|
|
enum CloseBehavior {
|
|
minimizeToTray,
|
|
close,
|
|
}
|
|
|
|
enum AudioSource {
|
|
youtube,
|
|
piped,
|
|
jiosaavn,
|
|
invidious;
|
|
|
|
String get label => name[0].toUpperCase() + name.substring(1);
|
|
}
|
|
|
|
enum YoutubeClientEngine {
|
|
ytDlp("yt-dlp"),
|
|
youtubeExplode("YouTubeExplode"),
|
|
newPipe("NewPipe");
|
|
|
|
final String label;
|
|
|
|
const YoutubeClientEngine(this.label);
|
|
|
|
bool isAvailableForPlatform() {
|
|
return switch (this) {
|
|
YoutubeClientEngine.youtubeExplode =>
|
|
YouTubeExplodeEngine.isAvailableForPlatform,
|
|
YoutubeClientEngine.ytDlp => YtDlpEngine.isAvailableForPlatform,
|
|
YoutubeClientEngine.newPipe => NewPipeEngine.isAvailableForPlatform,
|
|
};
|
|
}
|
|
}
|
|
|
|
enum MusicCodec {
|
|
m4a._("M4a (Best for downloaded music)"),
|
|
weba._("WebA (Best for streamed music)\nDoesn't support audio metadata");
|
|
|
|
final String label;
|
|
const MusicCodec._(this.label);
|
|
}
|
|
|
|
enum SearchMode {
|
|
youtube._("YouTube"),
|
|
youtubeMusic._("YouTube Music");
|
|
|
|
final String label;
|
|
|
|
const SearchMode._(this.label);
|
|
|
|
factory SearchMode.fromString(String key) {
|
|
return SearchMode.values.firstWhere((e) => e.name == key);
|
|
}
|
|
}
|
|
|
|
class PreferencesTable extends Table {
|
|
IntColumn get id => integer().autoIncrement()();
|
|
TextColumn get audioQuality => textEnum<SourceQualities>()
|
|
.withDefault(Constant(SourceQualities.high.name))();
|
|
BoolColumn get albumColorSync =>
|
|
boolean().withDefault(const Constant(true))();
|
|
BoolColumn get amoledDarkTheme =>
|
|
boolean().withDefault(const Constant(false))();
|
|
BoolColumn get checkUpdate => boolean().withDefault(const Constant(true))();
|
|
BoolColumn get normalizeAudio =>
|
|
boolean().withDefault(const Constant(false))();
|
|
BoolColumn get showSystemTrayIcon =>
|
|
boolean().withDefault(const Constant(false))();
|
|
BoolColumn get systemTitleBar =>
|
|
boolean().withDefault(const Constant(false))();
|
|
BoolColumn get skipNonMusic => boolean().withDefault(const Constant(false))();
|
|
TextColumn get fileNameFormat => textEnum<FileNameFormat>()
|
|
.withDefault(Constant(FileNameFormat.titleArtists.name))();
|
|
TextColumn get closeBehavior => textEnum<CloseBehavior>()
|
|
.withDefault(Constant(CloseBehavior.close.name))();
|
|
TextColumn get accentColorScheme => text()
|
|
.withDefault(const Constant("Orange:0xFFf97315"))
|
|
.map(const SpotubeColorConverter())();
|
|
TextColumn get layoutMode =>
|
|
textEnum<LayoutMode>().withDefault(Constant(LayoutMode.adaptive.name))();
|
|
TextColumn get locale => text()
|
|
.withDefault(
|
|
const Constant('{"languageCode":"system","countryCode":"system"}'),
|
|
)
|
|
.map(const LocaleConverter())();
|
|
TextColumn get market =>
|
|
textEnum<Market>().withDefault(Constant(Market.US.name))();
|
|
TextColumn get searchMode =>
|
|
textEnum<SearchMode>().withDefault(Constant(SearchMode.youtube.name))();
|
|
TextColumn get downloadLocation => text().withDefault(const Constant(""))();
|
|
TextColumn get localLibraryLocation =>
|
|
text().withDefault(const Constant("")).map(const StringListConverter())();
|
|
TextColumn get pipedInstance =>
|
|
text().withDefault(const Constant("https://pipedapi.kavin.rocks"))();
|
|
TextColumn get invidiousInstance =>
|
|
text().withDefault(const Constant("https://inv.nadeko.net"))();
|
|
TextColumn get themeMode =>
|
|
textEnum<ThemeMode>().withDefault(Constant(ThemeMode.system.name))();
|
|
TextColumn get audioSource =>
|
|
textEnum<AudioSource>().withDefault(Constant(AudioSource.youtube.name))();
|
|
TextColumn get youtubeClientEngine => textEnum<YoutubeClientEngine>()
|
|
.withDefault(Constant(YoutubeClientEngine.youtubeExplode.name))();
|
|
TextColumn get streamMusicCodec =>
|
|
textEnum<SourceCodecs>().withDefault(Constant(SourceCodecs.weba.name))();
|
|
TextColumn get downloadMusicCodec =>
|
|
textEnum<SourceCodecs>().withDefault(Constant(SourceCodecs.m4a.name))();
|
|
BoolColumn get discordPresence =>
|
|
boolean().withDefault(const Constant(true))();
|
|
BoolColumn get endlessPlayback =>
|
|
boolean().withDefault(const Constant(true))();
|
|
BoolColumn get enableConnect =>
|
|
boolean().withDefault(const Constant(false))();
|
|
BoolColumn get cacheMusic => boolean().withDefault(const Constant(true))();
|
|
|
|
// Default values as PreferencesTableData
|
|
static PreferencesTableData defaults() {
|
|
return PreferencesTableData(
|
|
id: 0,
|
|
audioQuality: SourceQualities.high,
|
|
albumColorSync: true,
|
|
amoledDarkTheme: false,
|
|
checkUpdate: true,
|
|
normalizeAudio: false,
|
|
showSystemTrayIcon: false,
|
|
systemTitleBar: false,
|
|
skipNonMusic: false,
|
|
fileNameFormat: FileNameFormat.titleArtists,
|
|
closeBehavior: CloseBehavior.close,
|
|
accentColorScheme: SpotubeColor(Colors.orange.value, name: "Orange"),
|
|
layoutMode: LayoutMode.adaptive,
|
|
locale: const Locale("system", "system"),
|
|
market: Market.US,
|
|
searchMode: SearchMode.youtube,
|
|
downloadLocation: "",
|
|
localLibraryLocation: [],
|
|
pipedInstance: "https://pipedapi.kavin.rocks",
|
|
invidiousInstance: "https://inv.nadeko.net",
|
|
themeMode: ThemeMode.system,
|
|
audioSource: AudioSource.youtube,
|
|
youtubeClientEngine: YoutubeClientEngine.youtubeExplode,
|
|
streamMusicCodec: SourceCodecs.m4a,
|
|
downloadMusicCodec: SourceCodecs.m4a,
|
|
discordPresence: true,
|
|
endlessPlayback: true,
|
|
enableConnect: false,
|
|
cacheMusic: true,
|
|
);
|
|
}
|
|
}
|