Example #1
0
        private static async Task <SavingError> SaveLastTrackLevel2(LastTrack track)
        {
            if (track == null)
            {
                return(SavingError.Unknown);
            }
            var alreadySaving = LastfmSavingTracks.FirstOrDefault(p => p == track.Id) != null;

            if (alreadySaving)
            {
                return(SavingError.AlreadySaving);
            }

            LastfmSavingTracks.Add(track.Id);
            while (!App.Locator.CollectionService.IsLibraryLoaded)
            {
            }
            var startTransaction = !App.Locator.SqlService.DbConnection.IsInTransaction;

            if (startTransaction)
            {
                App.Locator.SqlService.BeginTransaction();
            }
            var result = await SaveLastTrackLevel3(track);

            if (startTransaction)
            {
                App.Locator.SqlService.Commit();
            }
            ShowResults(result.Error, track.Name);
            LastfmSavingTracks.Remove(track.Id);

            if (result.Song != null)
            {
                if (!result.Song.Album.HasArtwork && !result.Song.Album.NoArtworkFound)
                {
                    if (track.Images != null && track.Images.Largest != null)
                    {
                        await DownloadArtworks.SaveAlbumImageAsync(result.Song.Album, track.Images.Largest.AbsoluteUri);
                    }
                    else
                    {
                        await DownloadArtworks.DownloadAlbumsArtworkAsync();
                    }
                }
            }

            if (App.Locator.Setting.SpotifyArtworkSync)
            {
                await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify(false, result.Song.Artist.Name);
            }
            else
            {
                await DownloadArtworks.DownloadArtistsArtworkAsync(false, result.Song.Artist.Name);
            }
            return(result.Error);
        }
Example #2
0
        async void GetMetadata()
        {
            Bar.IsIndeterminate = true;

            LocalMusicHelper localMusicHelper = new LocalMusicHelper();
            var localMusic = await localMusicHelper.GetFilesInMusicAsync();

            var failedCount = 0;

            Bar.IsIndeterminate = false;

            App.Locator.CollectionService.Songs.SuppressEvents   = true;
            App.Locator.CollectionService.Artists.SuppressEvents = true;
            App.Locator.CollectionService.Albums.SuppressEvents  = true;

            Bar.Maximum = localMusic.Count;
            App.Locator.SqlService.BeginTransaction();

            for (var i = 0; i < localMusic.Count; i++)
            {
                Bar.Value = i + 1;
                try
                {
                    await localMusicHelper.SaveTrackAsync(localMusic[i]);
                }
                catch
                {
                    failedCount++;
                }
            }
            App.Locator.SqlService.Commit();

            App.Locator.CollectionService.Songs.Reset();
            App.Locator.CollectionService.Artists.Reset();
            App.Locator.CollectionService.Albums.Reset();


            UiBlockerUtility.Unblock();
            ScreenTimeoutHelper.AllowTimeout();
            if (App.Locator.Setting.SpotifyArtworkSync)
            {
                await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
            }
            else
            {
                await DownloadArtworks.DownloadArtistsArtworkAsync();
            }

            await DownloadArtworks.DownloadAlbumsArtworkAsync();

            localSettings.Values[Core.PlayerConstants.UpdateAppString] = true;

            isDone = true;
            ButtonClick(null, null);
        }
Example #3
0
 async void GetArtwork()
 {
     if (App.Locator.Setting.SpotifyArtworkSync)
     {
         await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
     }
     else
     {
         await DownloadArtworks.DownloadArtistsArtworkAsync();
     }
 }
Example #4
0
        private async void ArtistArtworkSync(object sender, RoutedEventArgs e)
        {
            ToastManager.Show("Downloading missing artworks.");
            await DownloadArtworks.DownloadAlbumsArtworkAsync();

            if (App.Locator.Setting.SpotifyArtworkSync)
            {
                await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
            }
            else
            {
                await DownloadArtworks.DownloadArtistsArtworkAsync();
            }
        }
        async void ImportMusic(bool importVideo = false)
        {
            ScreenTimeoutHelper.PreventTimeout();

            Bar.IsIndeterminate = true;

            Message.Text = "Collecting information about music.";

            LocalMusicHelper localMusicHelper = new LocalMusicHelper();
            var localMusic = await localMusicHelper.GetFilesInMusicAsync();

            var failedCount = 0;

            Bar.IsIndeterminate = false;

            App.Locator.CollectionService.Songs.SuppressEvents   = true;
            App.Locator.CollectionService.Artists.SuppressEvents = true;
            App.Locator.CollectionService.Albums.SuppressEvents  = true;

            await Task.Delay(10);

            Message.Text = "Working on music files.";

            Bar.Maximum = localMusic.Count;

            App.Locator.SqlService.BeginTransaction();
            for (var i = 0; i < localMusic.Count; i++)
            {
                Bar.Value = i + 1;
                try
                {
                    await localMusicHelper.SaveTrackAsync(localMusic[i]);
                }
                catch
                {
                    failedCount++;
                }
            }
            App.Locator.SqlService.Commit();

            App.Locator.CollectionService.Songs.Reset();
            App.Locator.CollectionService.Artists.Reset();
            App.Locator.CollectionService.Albums.Reset();

            if (importVideo)
            {
                if (App.Locator.Setting.SpotifyArtworkSync)
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
                }
                else
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsync();
                }
                await DownloadArtworks.DownloadAlbumsArtworkAsync();

                ImportVideos();
            }
            else
            {
                if (App.Locator.Setting.SpotifyArtworkSync)
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
                }
                else
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsync();
                } await DownloadArtworks.DownloadAlbumsArtworkAsync();

                ScreenTimeoutHelper.AllowTimeout();
                SheetUtility.CloseImportRefreshPage();
            }

            App.Locator.HomePage.SongColletionChanged();
        }