void findTimestamp(Picasa.Photo picasaPhoto) { try { GoogleTimestamp = DateTimeExtensions.FromMillisecondsSinceEpoch(picasaPhoto.Timestamp); } catch (OverflowException) { GoogleTimestamp = DateTime.Now; Log.Debug("F**k: ", GoogleTimestamp.ToString()); } }
void findFilename(GooglePhotosService service, Picasa.Photo picasaPhoto) { string filename = picasaPhoto.Title; // the file name has to be platform independent filename = filename.Replace(":", "_").Trim('_', '.', ' ', '~'); // the file ending has to be in lower case filename = System.IO.Path.GetFileNameWithoutExtension(filename) + System.IO.Path.GetExtension(filename).ToLower(); string betterFilename = filename; string username = service.Auth.Account.ShortDisplayName; if (filename == "MOVIE.m4v") { betterFilename = "MOVIE_" + GoogleTimestamp.ToString("yyyyMMdd_HHmmss") + ".m4v"; } if (!FilenameUtilities.IsPreferredFileName(betterFilename)) { DateTime preferredDate; // get the date from the filename or use google's timestamp DateTime date; if (FilenameUtilities.GetFileNameDate(fileName: betterFilename, date: out date) && DateTimeExtensions.HasTimeComponent(date)) { preferredDate = date; } else { preferredDate = GoogleTimestamp; } betterFilename = FilenameUtilities.MakePreferredFileName(fileName: betterFilename, date: preferredDate, author: username); } if (FilenameUtilities.HasNoFileEnding(fullPath: betterFilename)) { string mimeType = picasaPhoto.PicasaEntry.Content.Type; string fileEnding = MimeTypes.ExtensionFromMimeType(mimeType: mimeType); // determine the best file ending if (fileEnding != null) { // rename the file filename += fileEnding; betterFilename += fileEnding; //Log.Debug ("Filename with ending: ", betterFilename); } } betterFilename = regexIllegalCharacters.Replace(betterFilename, ""); BestFilename = betterFilename; AlternateFilename = filename; //Log.Debug ("Filename for download: ", BestFilename); }