public ActionResult About() { string user = "******"; PicasaService service = new PicasaService("PhotoBrowser"); service.setUserCredentials(user, "**********"); AlbumQuery query = new AlbumQuery(); query.Uri = new Uri(PicasaQuery.CreatePicasaUri(user)); PicasaFeed picasaFeed = service.Query(query); List <PicasaEntry> result = new List <PicasaEntry>(); if (picasaFeed != null && picasaFeed.Entries.Count > 0) { foreach (PicasaEntry entry in picasaFeed.Entries) { result.Add(entry); } } return(View(result)); }
public void Update_AlbumAtomUrl() { if (string.IsNullOrEmpty(AppSetting.AlbumAtomUrl)) { CreateGenericAlbum(); } else { if (totalPhotos == 0 || totalPhotos >= 990) { AlbumQuery query = new AlbumQuery(); query.Uri = new Uri(AppSetting.AlbumAtomUrl); var picasaFeed = PicasaService.Query(query); if (picasaFeed != null) { totalPhotos = (new AlbumAccessor((PicasaEntry)picasaFeed.Entries[0])).NumPhotos.ToInt(); } } if (totalPhotos >= 990) { CreateGenericAlbum(); totalPhotos = 0; } } }
public static IEnumerable <PicasaAlbum> GetAlbums() { var albums = new List <PicasaAlbum>(); PicasaService service = new PicasaService("PicasaUnlistedAlbums"); service.setUserCredentials(WebConfigurationManager.AppSettings["Username"], WebConfigurationManager.AppSettings["Password"]); AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); PicasaFeed feed = service.Query(query); var albumsToExclude = WebConfigurationManager.AppSettings["AlbumsToExclude"].Split(',').ToList(); foreach (var atomEntry in feed.Entries) { var entry = (PicasaEntry)atomEntry; if (albumsToExclude.Contains(entry.Title.Text) || entry.Title.Text.Contains("Hangout")) { continue; } var album = new PicasaAlbum { Title = entry.Title.Text, Thumbnail = entry.Media.Thumbnails[0].Url, Link = entry.AlternateUri.Content }; albums.Add(album); } return(albums); }
public AlbumQuery SearchForAlbum(string album) { SpotifyAPI api = new SpotifyAPI(); AlbumQuery returnedAlbum = api.GetAlbum(album); return(returnedAlbum); }
public void AlbumQueryConstructorTest() { string queryUri = "http://www.google.com/test"; string expected = "http://www.google.com/test?kind=album"; AlbumQuery target = new AlbumQuery(queryUri); Assert.AreEqual(new Uri(expected), target.Uri); }
public List <PicasaWebAlbum> QueryAlbums(BackgroundWorker worker, int overallJobPercent) { // Create an authentication factory to deal with logging in. GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); authFactory.AccountType = "GOOGLE_OR_HOSTED"; this.m_albumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); this.m_albumQuery.Access = PicasaQuery.AccessLevel.AccessAll; this.m_albumService = new PicasaService(authFactory.ApplicationName); this.m_albumService.RequestFactory = authFactory; // this.m_albumService.setUserCredentials(this.m_userName, this.m_password); //string token = this.m_albumService.QueryAuthenticationToken(); this.m_albumService.SetAuthenticationToken(this.mUserToken); List <PicasaWebAlbum> retval = new List <PicasaWebAlbum>(); decimal count = ((decimal)overallJobPercent / 100) * 10; int smallCount = (int)count; try { worker.ReportProgress(0, (object)"Creating proxy"); CreateAlbumProxy(); worker.ReportProgress(smallCount, (object)"Proxy created"); worker.ReportProgress(0, (object)"Querying google"); this.m_albumFeed = this.m_albumService.Query(this.m_albumQuery); worker.ReportProgress(smallCount, (object)"Done"); } catch (Exception e) { this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; retval = null; throw new Exception("PicasaReader failed when downloading album feed for " + this.m_userName, e); } if (this.m_albumFeed.Entries.Count > 0) { int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_albumFeed.Entries.Count), 0); worker.ReportProgress(0, (object)"Processing album data"); foreach (PicasaEntry entry in this.m_albumFeed.Entries) { AlbumAccessor ac = new AlbumAccessor(entry); retval.Add(new PicasaWebAlbum(entry.Title.Text, entry.Updated, ac.NumPhotos, Convert.ToUInt64(ac.Id))); worker.ReportProgress(percent, null); } } this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; return(retval); }
public async Task <AlbumModel> GetAlbum(int id) { var query = new AlbumQuery { Id = id }; var album = await _mediator.Send(query); return(album); }
private void TabSelectionChanged(object sender, SelectionChangedEventArgs e) { if (Tabs.SelectedIndex != prevTabIndex) { switch (Tabs.SelectedIndex) { case 0: if (trackPackage != CurrentSearchPackage) { TrackQuery.FindTracks(CurrentSearchPackage, Dispatcher); trackPackage = CurrentSearchPackage; } EnumerationsContainer.LibraryUi = LibraryUiMode.Songs; //Dispatcher.BeginInvoke(new Action(() => Scrolls(tracklist))); break; case 1: if (artPackage != CurrentSearchPackage) { ArtistQuery.FindArtists(CurrentSearchPackage, Dispatcher); artPackage = CurrentSearchPackage; artistList.RefreshUI(); } EnumerationsContainer.LibraryUi = LibraryUiMode.Artist; break; case 2: if (albPackage != CurrentSearchPackage) { AlbumQuery.FindAlbums(CurrentSearchPackage, Dispatcher); albPackage = CurrentSearchPackage; albumLst.RefreshUI(); } EnumerationsContainer.LibraryUi = LibraryUiMode.Album; break; case 3: if (genPackage != CurrentSearchPackage) { GenreQuery.FindGenres(CurrentSearchPackage, Dispatcher); albPackage = CurrentSearchPackage; genreLst.RefreshUI(); } EnumerationsContainer.LibraryUi = LibraryUiMode.Genre; break; } RefreshPlugs(); prevTabIndex = Tabs.SelectedIndex; } }
public AlbumsQuery(GooglePhotosService service) { this.service = service; AlbumQuery albumsQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); albumsQuery.ExtraParameters = "imgmax=d"; PicasaFeed albumsFeed = service.PicasaService.Query(albumsQuery); picasaAlbums = albumsFeed.Entries.OfType <PicasaEntry> ().ToArray(); }
private void buttonGetAlbumList_Click(object sender, EventArgs e) { authenticate(); string userName = comboLogin.Text; disableItemsForRun(); Thread thr = new Thread(new ThreadStart(delegate { try { AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(userName)); PicasaFeed feed = service.Query(query); Invoke(new MethodInvoker(delegate { listAlbums.Items.Clear(); albumMap.Clear(); foreach (PicasaEntry entry in feed.Entries) { AlbumAccessor ac = new AlbumAccessor(entry); listAlbums.Items.Add(ac.AlbumTitle); albumMap[ac.AlbumTitle] = ac; } if (feed.Entries.Count > 0) { listAlbums.SelectedIndex = 0; } buttonGetAlbumList.Enabled = true; updateItems(); })); } catch (Exception ex) { Invoke(new MethodInvoker(delegate { uploadLog.Text = "Album list upload failed: " + ex.Message + "\r\n"; listAlbums.Items.Clear(); albumMap.Clear(); updateItems(); })); } })); thr.Start(); }
/// <summary> /// Remove album /// </summary> /// <param name="id"></param> public void RemoveAlbum(int id) { for (int i = 0; i < albums.Count; i++) { if (albums[i].Id == id) { // Remove from database first, then from list AlbumQuery.RemoveAlbum(albums[i].Id); albums.RemoveAt(i); } } }
void dpt_Tick(object sender, System.EventArgs e) { ticks++; if (incremented | Player.Instance.NetStreamingConfigsLoaded) { return; } if (Player.Instance.Wave != null && ticks > Player.Instance.Wave.Duration / 2 | ticks > 4000) { incremented = true; EventHandler handler = IncrementListens; if (handler != null) { handler(this, EventArgs.Empty); } //track update Track existingTrack = TrackQuery.GetTrack(CoreMain.CurrentTrack.Path); if (existingTrack != null) { existingTrack.Listens++; TrackQuery.SaveTrack(existingTrack); } //artistUpdate ArtistViewModel existingArtist = ArtistQuery.GetArtistViewModel(CoreMain.CurrentTrack.Artist); if (existingArtist != null) { existingArtist.Listens++; existingArtist.SaveArtist(); } //albumUpdate AlbumViewModel existingAlbum = AlbumQuery.GetAlbumViewModel(CoreMain.CurrentTrack.Album); if (existingAlbum != null) { existingAlbum.Listens++; existingAlbum.SaveAlbum(); } //a;bumUpdate ViewModels.GenreViewModel existingGenre = GenreQuery.GetGenreViewModel(CoreMain.CurrentTrack.Genre); if (existingGenre != null) { existingGenre.Listens++; existingGenre.SaveGenre(); } //scrobble LastFm.ScrobbleTrack(LastFm.CurrentTrack); } }
public PagedList <AlbumSummary> ListAlbums(int page, int pageSize) { var query = new AlbumQuery(PicasaQuery.CreatePicasaUri(PicasaConfiguration.Settings.Gallery.User)) { Thumbsize = PicasaConfiguration.Settings.Pictures.ThumbnailSize.ToString(), StartIndex = (page - 1) * pageSize + 1, NumberToRetrieve = pageSize }; var feed = GetPicasaFeed(query); var items = from PicasaEntry pictureEntry in feed.Entries select PicasaDataMapper.MapPicasaAlbum(pictureEntry); items = items.Where(item => item.Title != "Profile Photos" && item.Title != "Scrapbook Photos"); return(new PagedList <AlbumSummary>(items, Utils.CalculatePageNumber(feed.StartIndex, feed.ItemsPerPage), feed.ItemsPerPage, Utils.CalculatePageNumber(feed.TotalResults, feed.ItemsPerPage))); }
public void DownloadMetadata() { AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(Username)); query.ExtraParameters += "imgmax=d"; // passing this param allows us to get the original image size. PicasaFeed feed = Service.Query(query); foreach (PicasaEntry entry in feed.Entries) { Album album = GetAlbum(entry); this.Albums.Add(album); this.TotalImageCount += album.NumPhotos; } }
/// <summary> /// Syncs a local folder to an online Picasa Web Album location /// </summary> /// <param name="folderPath">The source folder to sync.</param> public void SyncFolder(string folderPath) { ResetCounters(); PicasaService session = new PicasaService("PicasaWebSync"); session.setUserCredentials(this.PicasaUsername, this.PicasaPassword); AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername)); try { WriteOutput("[Connecting to Picasa web service]"); //fetch all albums PicasaFeed albumFeed = session.Query(query); WriteOutput("[Starting sync]"); folderPath = folderPath.TrimEnd(new char[] { '\\' }); DirectoryInfo sourceFolder = new DirectoryInfo(folderPath); m_baseDirectoryName = sourceFolder.Name; SyncFolder(sourceFolder, null, this.AlbumAccess, this.IncludeSubFolders, session, albumFeed); } catch (GDataRequestException gdrex) { if (gdrex.ResponseString.Contains(GDATA_RESPONSE_BADAUTH)) { throw new AuthenticationException("Picasa error - username and/or password is incorrect! Check the config file values."); } else { throw new Exception(string.Format("Picasa error - {0}", gdrex.ResponseString)); } } WriteOutput("[Done]"); WriteOutput(string.Empty); WriteOutput("Summary:"); WriteOutput(string.Format(" Folders skipped: {0}", m_folderSkipCount.ToString())); WriteOutput(string.Format(" Albums created: {0}", m_albumCreateCount.ToString())); WriteOutput(string.Format(" Albums updated: {0}", m_albumUpdateCount.ToString())); WriteOutput(string.Format(" Albums deleted: {0}", m_albumDeleteCount.ToString())); WriteOutput(string.Format(" Files uploaded: {0}", m_fileCreateCount.ToString())); WriteOutput(string.Format(" Files removed: {0}", m_fileDeleteCount.ToString())); WriteOutput(string.Format(" Files skipped: {0}", m_fileSkipCount.ToString())); WriteOutput(string.Format(" Errors occured: {0}", m_errorsCount.ToString())); WriteOutput(string.Format(" Elapsed time: {0}", (DateTime.Now - m_startTime).ToString())); }
public async Task GetAlbums() { // Arrange var options = new DbContextOptionsBuilder<MyAlbumDbContext>() .UseInMemoryDatabase(databaseName: "AlbumRepository_GetAlbums_MyAlbumDatabase") .Options; using (var context = new MyAlbumDbContext(options)) { IEnumerable<Album> seedAlbums = SeedAlbums(context); AlbumRepository albumRepository = new AlbumRepository(context); AlbumQuery filter = new AlbumQuery(); // Act var albums = await albumRepository.GetAlbums(filter); // Assert Assert.Equal(seedAlbums, albums); } }
public List <Album> GetList() { var service = new PicasaService("GPhotoSync"); service.SetAuthenticationToken(_credentials.AccessToken); var query = new AlbumQuery(); query.Thumbsize = "180"; query.Uri = new Uri(PicasaQuery.CreatePicasaUri(_credentials.User)); var feed = service.Query(query); if (feed != null) { var list = feed.Entries .OfType <PicasaEntry>() .Where(x => !IsPostEntry(x)) .OrderBy(x => x.Title.Text) .Select(x => { var accessor = new AlbumAccessor(x); var thumb = x.Media.Thumbnails[0]; using (var stream = service.Query(new Uri(thumb.Attributes["url"] as string))) { var ms = new MemoryStream(); stream.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); return(new Album { Id = accessor.Id, Title = accessor.AlbumTitle, ImageStream = ms, PhotoCount = (int)accessor.NumPhotos }); } }) .ToList(); return(list); } else { return(new List <Album>()); } }
public AlbumManager() { albums = new ObservableCollection <Album>(); //Retrive albums from database List <int> ints = AlbumQuery.GetAlbums(); if (ints.Count > 0) { for (int i = 0; i < ints.Count; i++) { // Re-create albums and add to list Album album = new Album(ints[i]); albums.Add(album); } } }
/// <summary> /// Constructor used to restore from database /// </summary> /// <param name="id"></param> public Album(int id) { AlbumMapper albumDataContent = AlbumQuery.GetAlbum(id); this.id = id; this.title = albumDataContent.Name; this.lastUsed = albumDataContent.LastUsed; this.slideShows = new ObservableCollection <SlideShow>(); //Get slideshows and restrore those List <int> slideShowIds = SlideShowQuery.GetSlideShows(id); foreach (int slideShowId in slideShowIds) { SlideShow slideShow = new SlideShow(slideShowId); this.slideShows.Add(slideShow); } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>tries to insert a photo using MIME multipart</summary> ////////////////////////////////////////////////////////////////////// [Test] public void InsertMimePhotoTest() { Tracing.TraceMsg("Entering InsertMimePhotoTest"); AlbumQuery query = new AlbumQuery(); PicasaService service = new PicasaService("unittests"); if (this.defaultPhotosUri != null) { if (this.userName != null) { service.Credentials = new GDataCredentials(this.userName, this.passWord); } query.Uri = new Uri(this.defaultPhotosUri); PicasaFeed feed = service.Query(query); if (feed != null) { Assert.IsTrue(feed.Entries != null, "the albumfeed needs entries"); Assert.IsTrue(feed.Entries[0] != null, "the albumfeed needs at least ONE entry"); PicasaEntry album = feed.Entries[0] as PicasaEntry; PhotoEntry newPhoto = new PhotoEntry(); newPhoto.Title.Text = "this is a title"; newPhoto.Summary.Text = "A lovely shot in the ocean"; newPhoto.MediaSource = new MediaFileSource(this.resourcePath + "testnet.jpg", "image/jpeg"); Uri postUri = new Uri(album.FeedUri.ToString()); PicasaEntry entry = service.Insert(postUri, newPhoto) as PicasaEntry; Assert.IsTrue(entry.IsPhoto, "the new entry should be a photo entry"); entry.Title.Text = "This is a new Title"; entry.Summary.Text = "A lovely shot in the shade"; entry.MediaSource = new MediaFileSource(this.resourcePath + "testnet.jpg", "image/jpeg"); PicasaEntry updatedEntry = entry.Update() as PicasaEntry; Assert.IsTrue(updatedEntry.IsPhoto, "the new entry should be a photo entry"); Assert.IsTrue(updatedEntry.Title.Text == "This is a new Title", "The titles should be identical"); Assert.IsTrue(updatedEntry.Summary.Text == "A lovely shot in the shade", "The summariesa should be identical"); } } }
protected void Page_Load(object sender, EventArgs e) { GotoAuthSubLink.Visible = false; if (Session["token"] != null) { Response.Redirect("Default.aspx"); } else if (Request.QueryString["token"] != null) { User u = new User(); u.Username = "******"; u.Password = "******"; PicasaService.setUserCredentials(u.Username, u.Password); AlbumQuery albumQuery = new AlbumQuery(); albumQuery.Uri = new Uri(PicasaQuery.CreatePicasaUri(u.Username)); //albumQuery.Access = PicasaQuery.AccessLevel.AccessPublic; PicasaFeed feed = PicasaService.Query(albumQuery); Session["feed"] = feed; Session["service"] = PicasaService; Session["user"] = u; if (feed.Entries.Count > 0) { AlbumAccessor myAlbum = new AlbumAccessor((PicasaEntry)feed.Entries[0]); Response.Redirect("Default.aspx?album=" + myAlbum.Id, true); } else { Response.Redirect("Default.aspx", true); } } else //no auth data, print link { GotoAuthSubLink.Text = "Login to your Google Account"; GotoAuthSubLink.Visible = true; GotoAuthSubLink.NavigateUrl = AuthSubUtil.getRequestUrl(Request.Url.ToString(), "https://picasaweb.google.com/data/", false, true); } }
protected virtual void Dispose(bool disposing) { if (!is_disposed) // only dispose once! { if (disposing) { m_albumService = null; m_albumFeed = null; m_albumQuery = null; m_photoService = null; m_photoQuery = null; m_photoFeed = null; m_userName = null; m_serviceName = null; m_albumName = null; } } this.is_disposed = true; }
/* public string LoginToGoogle(out string token) * { * GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); * authFactory.AccountType = "GOOGLE_OR_HOSTED"; * * this.m_albumService = new PicasaService(authFactory.ApplicationName); * try * { * this.m_albumService.setUserCredentials(this.m_userName, this.m_password); * this.m_albumService.QueryAuthenticationToken(); // Authenticate the user immediately * } * catch (CaptchaRequiredException e) * { * token = e.Token; * return e.Url; * } * } * * public string LoginToGoogle(out string token, string CAPTCHAAnswer, string CAPTCHAToken) * { * GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); * authFactory.AccountType = "GOOGLE_OR_HOSTED"; * string token = string.Empty; * this.m_albumService = new PicasaService(authFactory.ApplicationName); * authFactory.CaptchaAnswer = CAPTCHAAnswer; * authFactory.CaptchaToken = CAPTCHAToken; * this.m_albumService.setUserCredentials(this.m_userName, this.m_password); * * token = this.m_albumService.QueryAuthenticationToken(); // Authenticate the user immediately * return token; * * * } */ public List <PicasaWebAlbum> QueryAlbums() { // Create an authentication factory to deal with logging in. GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); authFactory.AccountType = "GOOGLE_OR_HOSTED"; this.m_albumService = new PicasaService(authFactory.ApplicationName); this.m_albumService.RequestFactory = authFactory; this.m_albumService.SetAuthenticationToken(this.mUserToken); this.m_albumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); this.m_albumQuery.Access = PicasaQuery.AccessLevel.AccessAll; List <PicasaWebAlbum> retval = new List <PicasaWebAlbum>(); try { CreateAlbumProxy(); this.m_albumFeed = this.m_albumService.Query(this.m_albumQuery); } catch (Exception e) { this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; retval = null; throw new Exception("PicasaReader failed when downloading album feed for " + this.m_userName, e); } foreach (PicasaEntry entry in this.m_albumFeed.Entries) { AlbumAccessor ac = new AlbumAccessor(entry); retval.Add(new PicasaWebAlbum(entry.Title.Text, entry.Updated, ac.NumPhotos, Convert.ToUInt64(ac.Id))); } this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; return(retval); }
public void DeleteEmptyAlbum() { //var atom = PicasaService.Get("https://picasaweb.google.com/data/entry/api/user/113917932111131696693"); AlbumQuery query = new AlbumQuery(); query.Uri = new Uri(PicasaQuery.CreatePicasaUri("113917932111131696693") + "?max-results=10000"); var picasaFeed = PicasaService.Query(query); if (picasaFeed != null && picasaFeed.Entries.Count > 0) { foreach (PicasaEntry entry in picasaFeed.Entries) { var num = entry.GetPhotoExtensionValue(GPhotoNameTable.NumPhotos).ToInt(); if (num == 0) { entry.Delete(); } } } }
private void UpdateAlbumFeed() { AlbumQuery query = new AlbumQuery(); this.AlbumList.Clear(); query.Uri = new Uri(PicasaQuery.CreatePicasaUri(this.user)); this.picasaFeed = this.picasaService.Query(query); if (this.picasaFeed != null && this.picasaFeed.Entries.Count > 0) { foreach (PicasaEntry entry in this.picasaFeed.Entries) { ListViewItem item = new ListViewItem(entry.Title.Text + " (" + entry.GetPhotoExtensionValue(GPhotoNameTable.NumPhotos) + " )"); item.Tag = entry; this.AlbumList.Items.Add(item); } } this.AlbumList.Update(); }
protected string GetAlbumsTable() { if (string.IsNullOrEmpty(Settings.GetSingleValue("Account"))) { return(string.Empty); } var service = new PicasaService("exampleCo-exampleApp-1"); string usr = Settings.GetSingleValue("Account") + "@gmail.com"; string pwd = Settings.GetSingleValue("Password"); service.setUserCredentials(usr, pwd); var sb = new StringBuilder("<table class=\"beTable\">"); var query = new AlbumQuery(PicasaQuery.CreatePicasaUri(usr)); PicasaFeed feed = service.Query(query); sb.Append(GetHeader()); var cnt = 0; foreach (PicasaEntry entry in feed.Entries) { var ac = new AlbumAccessor(entry); const string cell = "<td>{0}</td>"; sb.Append(cnt % 2 == 0 ? "<tr>" : "<tr class=\"alt\">"); // thumbnail string albumUri = ((Google.GData.Client.AtomEntry)(entry)).AlternateUri.ToString(); string firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string; string thumbAncr = string.Format("<a href=\"{2}\"><img src=\"{0}\" alt=\"{1}\" width=\"40\" /></a>", firstThumbUrl, entry.Title.Text, albumUri); sb.Append(string.Format(cell, thumbAncr)); // title sb.Append(string.Format(cell, ac.AlbumTitle)); // description sb.Append(string.Format(cell, ac.AlbumSummary + " ")); // number of photos sb.Append(string.Format(cell, ac.NumPhotos)); // access sb.Append(string.Format(cell, ac.Access)); // extension tag string feedUri = entry.FeedUri; const string showTag = "[PicasaShow:{0}]"; const string albmTag = "[PicasaAlbum:{0}]"; if (ac.Access.ToLower() == "protected") { sb.Append(string.Format(cell, " ")); sb.Append(string.Format(cell, " ")); } else { sb.Append(string.Format(cell, string.Format(showTag, ac.AlbumTitle))); sb.Append(string.Format(cell, string.Format(albmTag, ac.AlbumTitle))); } sb.Append("</tr>"); cnt++; } return(sb + "</table>"); }
public void AlbumQueryConstructorTest1() { AlbumQuery target = new AlbumQuery(); Assert.IsNotNull(target); }
public static TrackViewModel AddFile(string file) { try { var d = new TrackViewModel(); //Build tags TrackViewModel track = TaglibCore.BuildTrack(file); try { //Save Track track.SaveTrack(); } catch (Exception exception) { Console.WriteLine(exception); } //============== //Artists //============== //Do the operations for artists ArtistViewModel art = ArtistQuery.GetArtistViewModel(track.Artist); art = art ?? new ArtistViewModel(); art.Name = track.Artist; art.Duration += track.Duration; art.SongCount++; art.SaveArtist(); //============== //Genre //============== ViewModels.GenreViewModel gens = GenreQuery.GetGenreViewModel(track.Genre); gens = gens ?? new ViewModels.GenreViewModel(); gens.Name = track.Genre; gens.Duration += track.Duration; gens.SongCount++; gens.SaveGenre(); //============== //Albums //============== AlbumViewModel albs = AlbumQuery.GetAlbumViewModel(track.Album); albs = albs ?? new AlbumViewModel(); albs.Name = track.Album; albs.Artist = track.Artist; albs.Duration += track.Duration; albs.SongCount++; albs.ID = track.Album; albs.SaveAlbum(); if (track.Album.ToLower() != "unknown album") { //Global.SaveAlbumArt(album + " - " + Artists, tgl.getArtStream()); //opt.SaveThumb("My Library\\AlbumArt\\" + album + " - " + Artists + ".jpg.thumb"); } Tracks.Add(track); Artists.Add(art); Albums.Add(albs); Genres.Add(gens); App.Current.Dispatcher.Invoke(new Action(() => { var mw = App.Current.MainWindow as MainWindow; if (mw != null) { if (mw.hLibrary.grdDD.Visibility == Visibility.Visible) { mw.hLibrary.grdDD.FadeOut(); } } if (SOFilter.ValidGenre(Results.TrackSearch, gens)) { Results.Genres.Add(gens); } if (SOFilter.ValidArtist(Results.TrackSearch, art)) { Results.Artists.Add(art); } if (SOFilter.ValidAlbum(Results.TrackSearch, albs)) { Results.Albums.Add(albs); } if (SOFilter.ValidTrack(Results.TrackSearch, track)) { Results.Tracks.Add(track); } })); return(track); } catch { } return(null); }
/// <summary> /// Workers load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void worker_load(object sender, DoWorkEventArgs e) { //Load lists //InitializeLists(); if (Results.Tracks == null) { Results.Tracks = new ObservableCollection <TrackViewModel>(); } if (Results.Artists == null) { Results.Artists = new ObservableCollection <ArtistViewModel>(); } if (Results.Albums == null) { Results.Albums = new ObservableCollection <AlbumViewModel>(); } if (Results.Genres == null) { Results.Genres = new ObservableCollection <ViewModels.GenreViewModel>(); } DB_InUse = true; try { NotifyPropertyChanged("Initialized"); App.Current.Dispatcher.BeginInvoke(new Action(() => { if (ListenToChanges != null) { ListenToChanges(new TrackViewModel() { Title = "Searching" }, SearchGuid); } })); files = Search(@path, "*.*") .Where( s => s.ToLower().EndsWith(".mp3") || s.ToLower().EndsWith(".wma") || s.ToLower().EndsWith(".flac") || s.ToLower().EndsWith(".ogg") || s.ToLower().EndsWith(".wav") || s.ToLower().EndsWith(".mp2") || s.ToLower().EndsWith(".mp1") || s.ToLower().EndsWith(".m4a")); ; max = files.Count(); NotifyPropertyChanged("New Count"); } catch { } //NotifyPropertyChanged("New Count"); //tag data holding variables int mval = 0; if (files == null) // if there is nothin in files, return { //Settings.Default.LibSearchPath = ""; //Settings.Default.LibSearchCompleted = true; Settings.Default.Save(); return; } var artists = new Dictionary <string, ArtistViewModel>(); var albums = new Dictionary <string, AlbumViewModel>(); var genres = new Dictionary <string, ViewModels.GenreViewModel>(); Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = 1 }, file => { if (GlobalSearchCancel) { return; } try { var d = new TrackViewModel(); //Build tags TrackViewModel track = TaglibCore.BuildTrack(file); try { //Save Track if (!string.IsNullOrEmpty(track.Title) && track.SaveTrack() == "success") { App.Current.Dispatcher.BeginInvoke(new Action(() => { if (SOFilter.ValidTrack(Results.TrackSearch, track)) { if (!Results.Tracks.Contains(track)) { Results.Tracks.Add(track); } } })); } } catch (Exception exception) { Console.WriteLine(exception); } //============== //Artists //============== //Add the artist to dictionary from DB if the dictionary doesnt have already if (!artists.ContainsKey(track.Artist)) { ArtistViewModel arts = ArtistQuery.GetArtistViewModel(track.Artist); if (arts != null) { artists.Add(track.Artist, arts); } else { artists.Add(track.Artist, new ArtistViewModel()); } } //Do the operations for artists ArtistViewModel art = artists[track.Artist]; art.Name = track.Artist; art.Duration += track.Duration; art.SongCount++; art.SaveArtist(); App.Current.Dispatcher.BeginInvoke(new Action(() => { if (SOFilter.ValidArtist(Results.TrackSearch, art)) { ArtistViewModel exar; try { exar = Results.Artists.Single(c => c.Name == art.Name); } catch (Exception exception) { exar = null; } if (exar == null) { Results.Artists.Add(art); } else { exar.Listens = art.Listens; exar.Duration = art.Duration; exar.SongCount = art.SongCount; exar.Name = art.Name; } } })); //============== //Genre //============== //Add the album to dictionary from DB if the dictionary doesnt have already if (!genres.ContainsKey(track.Genre)) { ViewModels.GenreViewModel al = GenreQuery.GetGenreViewModel(track.Genre); if (al != null) { genres.Add(track.Genre, al); } else { genres.Add(track.Genre, new ViewModels.GenreViewModel()); } } ViewModels.GenreViewModel gens = genres[track.Genre]; gens.Name = track.Genre; gens.Duration += track.Duration; gens.SongCount++; gens.SaveGenre(); App.Current.Dispatcher.BeginInvoke(new Action(() => { if (SOFilter.ValidGenre(Results.TrackSearch, gens)) { ViewModels.GenreViewModel exar; try { exar = Results.Genres.Single(c => c.Name == gens.Name); } catch (Exception exception) { exar = null; } if (exar == null) { Results.Genres.Add(gens); } else { exar.Listens = art.Listens; exar.Duration = art.Duration; exar.SongCount = art.SongCount; exar.Name = art.Name; } } })); //============== //Albums //============== //Add the genre to dictionary from DB if the dictionary doesnt have already if (!albums.ContainsKey(track.Album)) { AlbumViewModel al = AlbumQuery.GetAlbumViewModel(track.Album); if (al != null) { albums.Add(track.Album, al); } else { albums.Add(track.Album, new AlbumViewModel()); } } AlbumViewModel albs = albums[track.Album]; albs.Name = track.Album; albs.Artist = track.Artist; albs.Duration += track.Duration; albs.SongCount++; albs.ID = track.Album; albs.SaveAlbum(); App.Current.Dispatcher.BeginInvoke(new Action(() => { if (SOFilter.ValidAlbum(Results.TrackSearch, albs)) { AlbumViewModel exar; try { exar = Results.Albums.Single(c => c.ID == albs.ID); } catch (Exception exception) { exar = null; } if (exar == null) { Results.Albums.Add(albs); } else { exar.Listens = art.Listens; exar.Duration = art.Duration; exar.SongCount = art.SongCount; exar.Name = art.Name; } } })); if (track.Album.ToLower() != "unknown album") { //Global.SaveAlbumArt(album + " - " + Artists, tgl.getArtStream()); //opt.SaveThumb("My Library\\AlbumArt\\" + album + " - " + Artists + ".jpg.thumb"); } if (!Tracks.Any(c => c.Path == track.Path)) { Tracks.Add(track); } if (!Artists.Any(c => c.Name == art.Name)) { Artists.Add(art); } if (!Albums.Any(c => c.Name == albs.Name)) { Albums.Add(albs); } if (!Genres.Any(c => c.Name == gens.Name)) { Genres.Add(gens); } //Playlist callbacks triggerCallback(track, SearchGuid); ListenToChanges(track, SearchGuid); } catch { } mval += 1; cworker.ReportProgress(mval); }); }
/// <summary> /// returns the list of Albums for the default user /// </summary> public Feed <Album> GetAlbums() { AlbumQuery q = PrepareQuery <AlbumQuery>(PicasaQuery.CreatePicasaUri(Utilities.DefaultUser)); return(PrepareFeed <Album>(q)); }