private static bool ProcessAlbumDirectory(string path) { if (!Directory.Exists(path)) { throw new ArgumentException($"The path '{path}' was not found."); } DirectoryInfo dirInfo = new DirectoryInfo(path); string albumtitle = dirInfo.Name; Console.WriteLine(); Console.WriteLine($"Uploading Album: {albumtitle}"); MyAlbum album = new MyAlbum(service, albumtitle, dirInfo); bool albumuploadresult = album.UploadAlbum(); if (!albumuploadresult) { Console.WriteLine("WARNING: One or more issues occured during the Upload. Please check the log."); return(false); } Console.WriteLine($"Album '{albumtitle}' including {album.ImageUploadCount} images uploaded to Google Photos!"); return(true); }
public void Update_LibraryArtists() { try { MediaLibrary MLibrary = new MediaLibrary(); Offline_Artist.Clear(); foreach (Artist ar in MLibrary.Artists) { MyArtist temp = new MyArtist(); temp.Name = ar.Name; foreach (Song so in ar.Songs) { MySong t1 = new MySong(); t1.Name = so.Name; //t1.Genre = so.Genre.Name; t1.Artist.Name = so.Artist.Name; t1.Album.Name = so.Album.Name; temp.Songs.Add(t1); } foreach (Album al in ar.Albums) { MyAlbum t1 = new MyAlbum(); t1.Name = al.Name; t1.Artist.Name = al.Artist.Name; temp.Albums.Add(t1); } Offline_Artist.Add(temp); } } catch { } }
public void Update_LibraryAlbums() { MediaLibrary MLibrary = new MediaLibrary(); Offline_Album.Clear(); foreach (Album ar in MLibrary.Albums) { MyAlbum temp = new MyAlbum(); temp.Name = ar.Name; foreach (Song so in ar.Songs) { MySong t1 = new MySong(); t1.Name = so.Name; //t1.Genre = so.Genre.Name; t1.Artist.Name = so.Artist.Name; t1.Album.Name = so.Album.Name; temp.Songs.Add(t1); } temp.Artist.Name = ar.Artist.Name; Offline_Album.Add(temp); } }
public static void ListAlbums() { MyAlbum.ListAlbums(service); }
public static void ListAlbums() { MyAlbum.ListAlbums(service, _logger); }
private static (bool uploadResult, string uploadResultText) ProcessAlbumDirectory(string path) { try { if (!Directory.Exists(path)) { throw new ArgumentException($"The path '{path}' was not found."); } DirectoryInfo dirInfo = new DirectoryInfo(path); string albumtitle = dirInfo.Name; Console.WriteLine(); Console.WriteLine($"Uploading Album: {albumtitle}"); MyAlbum album = new MyAlbum(_logger, service, albumtitle, dirInfo); //Does the album already exist? if (!album.IsAlbumNew) { if (!album.IsAlbumWritable) { return(false, "Album not updated. For safety reasons then album created outside this utility is not updated."); } else { Console.Write("The album already exists, do you want to add any missing images to it? (y/n) "); try { char key = Console.ReadKey().KeyChar; if (key != 'y') { Console.WriteLine(); album.UploadStatus = UploadStatusEnum.UploadAborted; return(false, album.ToStringUploadResult()); } } catch (Exception e) { _logger.LogError(e, "An error occured when evaluating user input"); Console.WriteLine(); return(false, "An unexpected error occured, check the log"); } Console.WriteLine(); } } //Upload the album and images to Google Photos bool albumuploadresult = album.UploadAlbum(); //Upload complete, share the result return(true, album.ToStringUploadResult()); } catch (Exception ex) { _logger.LogError(ex, "An exception occured"); return(false, $"{path}: An exception occured during Album upload"); } }
public void ListAlbums() { MyAlbum.ListAlbums(service, logger); }
private (bool uploadResult, string uploadResultText) ProcessAlbumDirectoryUpload(string path, bool?addifalbumexists) { try { if (!Directory.Exists(path)) { throw new ArgumentException($"The path '{path}' was not found."); } DirectoryInfo dirInfo = new DirectoryInfo(path); //Verify there is sufficient disk space if (!SpaceAvailableForMediaFolder(dirInfo)) { return(false, "Album not uploaded. Not sufficient storage space in Google Photos."); } string albumtitle = dirInfo.Name; Console.WriteLine(); Console.WriteLine($"Uploading Album: {albumtitle}"); MyAlbum album = new MyAlbum(logger, service, albumtitle, dirInfo); //Verify the Album has not been cretaed outside this tool if (!album.IsAlbumNew && !album.IsAlbumWritable) { return(false, "Albums created outside this tool cannot be updated, for safety reasons."); } //Get User consent to update existing Album if (!album.IsAlbumNew) { //Ask user if existing Album should be updated, if answer not provided through program args if (addifalbumexists == null) { addifalbumexists = UserGrantedAlbumUpdate(); } if (addifalbumexists != true) { album.UploadStatus = UploadStatus.UploadAborted; logger.LogInformation("The album already exists and is not updated."); return(false, album.ToStringUploadResult()); } } //Upload the album and images to Google Photos album.UploadAlbum(); //Upload complete, share the result return(true, album.ToStringUploadResult()); } catch (Exception ex) { logger.LogError(ex, $"An exception occured during processing of '{path}'"); return(false, $"{path}: An exception occured during Album upload"); } }