Skip to content

Commit

Permalink
Updated some libraries, add limits to ytm api, default quality settings
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekYang2 committed Sep 19, 2024
1 parent 7836864 commit 564e438
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
6 changes: 3 additions & 3 deletions FluentDL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PackageReference Include="CommunityToolkit.WinUI.UI.Animations" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
<PackageReference Include="DeezNET" Version="1.1.1" />
<PackageReference Include="DeezNET" Version="1.2.0" />
<PackageReference Include="FFMpegCore" Version="5.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240627000" />
Expand All @@ -50,8 +50,8 @@
<PackageReference Include="SpotifyAPI.Web" Version="7.1.1" />
<PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Include="WinUIEx" Version="2.3.2" />
<PackageReference Include="YoutubeExplode" Version="6.4.0" />
<PackageReference Include="YouTubeMusicAPI" Version="1.1.4" />
<PackageReference Include="YoutubeExplode" Version="6.4.1" />
<PackageReference Include="YouTubeMusicAPI" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="e2a9b324-d68e-4e2d-9c36-70405ade87d9"
Publisher="CN=derek"
Version="1.0.0.0" />
Version="1.1.0.0" />

<mp:PhoneIdentity PhoneProductId="e2a9b324-d68e-4e2d-9c36-70405ade87d9" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
13 changes: 10 additions & 3 deletions Services/QobuzApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ public static async Task Initialize(string? userId, string? AuthToken)
{
await Task.Run(() =>
{
if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(AuthToken))
try
{
apiService.LoginWithToken(userId, AuthToken);
IsInitialized = true;
if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(AuthToken))
{
apiService.LoginWithToken(userId, AuthToken);
IsInitialized = true;
}
}
catch (Exception e)
{
Debug.WriteLine("Failed to init Qobuz: " + e.Message);
}
});
}
Expand Down
12 changes: 6 additions & 6 deletions Services/YoutubeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static async Task GeneralSearch(ObservableCollection<SongSearchObject> it

try
{
searchResults = await ytm.SearchAsync<Song>(query, token);
searchResults = await ytm.SearchAsync<Song>(query, limit, token);
}
catch (Exception e)
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public static async Task AdvancedSearch(ObservableCollection<SongSearchObject> i

if (!string.IsNullOrWhiteSpace(albumName)) // Album was specified
{
var searchResults = await ytm.SearchAsync<Album>(albumName, token); // Search for album first
var searchResults = await ytm.SearchAsync<Album>(albumName, 15, token); // Search for album first

if (token.IsCancellationRequested) return; // If cancelled

Expand Down Expand Up @@ -246,7 +246,7 @@ public static async Task AdvancedSearch(ObservableCollection<SongSearchObject> i
if (isTrackSpecified) // If artist and track are specified
{
var query = artistName + " " + trackName;
var searchResults = await ytm.SearchAsync<Song>(query, token);
var searchResults = await ytm.SearchAsync<Song>(query, 2 * limit, token);
if (token.IsCancellationRequested) return; // If cancelled

foreach (var song in searchResults)
Expand Down Expand Up @@ -275,7 +275,7 @@ public static async Task AdvancedSearch(ObservableCollection<SongSearchObject> i
}
else // If only artist is specified
{
var artistResults = await ytm.SearchAsync<Artist>(artistName, token);
var artistResults = await ytm.SearchAsync<Artist>(artistName, 15, token);
if (token.IsCancellationRequested) return; // If cancelled

foreach (var artistResult in artistResults)
Expand Down Expand Up @@ -550,7 +550,7 @@ public static async Task<VideoSearchResult> GetSearchResult(SongSearchObject son
IEnumerable<Album>? searchResults = null;
try
{
searchResults = await ytm.SearchAsync<Album>(albumName, token); // Search for album first
searchResults = await ytm.SearchAsync<Album>(albumName, 15, token); // Search for album first
}
catch (Exception e)
{
Expand Down Expand Up @@ -627,7 +627,7 @@ public static async Task<VideoSearchResult> GetSearchResult(SongSearchObject son

// Try searching without album
var query = artistName + " " + trackName;
var searchResults2 = await ytm.SearchAsync<Song>(query, token);
var searchResults2 = await ytm.SearchAsync<Song>(query, 20, token);

if (token.IsCancellationRequested) return null; // If cancelled

Expand Down
10 changes: 5 additions & 5 deletions Views/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ private async void SettingsPage_Loaded(object sender, RoutedEventArgs e)
CommandThreadsSlider.Value = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.CommandThreads) ?? 1;
AudioConversionThreadsSlider.Value = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.AudioConversionThreads) ?? 1;

// Set quality combo boxes
DeezerQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.DeezerQuality) ?? 0;
QobuzQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.QobuzQuality) ?? 0;
SpotifyQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.SpotifyQuality) ?? 0;
YoutubeQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.YoutubeQuality) ?? 0;
// Set quality combo boxes (default flac)
DeezerQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.DeezerQuality) ?? 2;
QobuzQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.QobuzQuality) ?? 1;
SpotifyQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.SpotifyQuality) ?? 1;
YoutubeQualityComboBox.SelectedIndex = await localSettings.ReadSettingAsync<int?>(SettingsViewModel.YoutubeQuality) ?? 1;

// Set download directory
LocationCard.Description = await localSettings.ReadSettingAsync<string>(SettingsViewModel.DownloadDirectory) ?? "No folder selected";
Expand Down

0 comments on commit 564e438

Please sign in to comment.