void serverSearch_Click(object sender, EventArgs e) { MainSection section = selectedServerSection as MainSection; ToolStripMenuItem tsi = sender as ToolStripMenuItem; SearchSection searchSection = tsi != null ? tsi.Tag as SearchSection : null; if (OnSearchInput != null && section != null && searchSection != null) { // Show search dialog string query = ""; if (OnSearchInput(searchSection, out query)) { LibrarySection librarySection = searchSection.createFromSearch(query); if (librarySection != null) { librarySection.IsMusic = section.IsMusic; // Add a new child node to the musicsection node TreeNode tn = tvServerSection.SelectedNode.Nodes.Add(librarySection.Key, librarySection.Title); tn.Tag = librarySection; // Select the newly added node in the tree tvServerSection.SelectedNode = tn; } } } }
public static string LibrarySectionToString(LibrarySection librarySection) { switch (librarySection) { case LibrarySection.CurrentlyWatching: return("currently-watching"); case LibrarySection.CurrentlyReading: return("currently-reading"); case LibrarySection.PlanToWatch: return("plan-to-watch"); case LibrarySection.PlanToRead: return("plan-to-read"); case LibrarySection.Completed: return("completed"); case LibrarySection.OnHold: return("on-hold"); case LibrarySection.Dropped: return("dropped"); case LibrarySection.All: case LibrarySection.Favourites: case LibrarySection.Recent: case LibrarySection.Search: case LibrarySection.None: default: return(""); } }
private async void GetLibrary_ButtonClick(object sender, RoutedEventArgs e) { APIProgress progress = new APIProgress(); progress.ProgressChanged += ProgressChanged_StatusReport; progress.ProgressChanged += ProgressChanged_GetLibrary; LibrarySection section = LibrarySection.None; switch (getLibrary_LibrarySelectionComboBox.SelectedIndex) { case 0: section = LibrarySection.All; break; case 1: section = LibrarySection.CurrentlyWatching; break; case 2: section = LibrarySection.PlanToWatch; break; case 3: section = LibrarySection.Completed; break; case 4: section = LibrarySection.OnHold; break; case 5: section = LibrarySection.Dropped; break; } getAnimeLibraryTask = HummingbirdV1.AnimeAPI.GetAnimeLibrary(getLibrary_usernameTextBox.Text, section, progress); }
public static string LibrarySectionToIntelligableStatusString(LibrarySection librarySection) { switch (librarySection) { case LibrarySection.CurrentlyWatching: return("is currently watching"); case LibrarySection.CurrentlyReading: return("is currently reading"); case LibrarySection.PlanToWatch: return("plans to watch"); case LibrarySection.PlanToRead: return("plans to read"); case LibrarySection.Completed: return("has completed"); case LibrarySection.OnHold: return("has placed on hold"); case LibrarySection.Dropped: return("has dropped"); case LibrarySection.Favourites: return("has favourited"); case LibrarySection.All: case LibrarySection.Recent: case LibrarySection.Search: case LibrarySection.None: default: return("has added to library"); // + LibrarySectionToIntelligableString(librarySection); } }
public static string LibrarySectionToIntelligableString(LibrarySection librarySection) { switch (librarySection) { case LibrarySection.CurrentlyWatching: return("Currently Watching"); case LibrarySection.CurrentlyReading: return("Currently Reading"); case LibrarySection.PlanToWatch: return("Plan to Watch"); case LibrarySection.PlanToRead: return("Plan to Read"); case LibrarySection.Completed: return("Completed"); case LibrarySection.OnHold: return("On Hold"); case LibrarySection.Dropped: return("Dropped"); case LibrarySection.Favourites: return("Favourite"); case LibrarySection.All: case LibrarySection.Recent: case LibrarySection.Search: case LibrarySection.None: default: return(librarySection.ToString()); } }
static void Main(string[] args) { var config = new PlexConfig(); Console.WriteLine("Hello to the plex server api test app."); do { Console.WriteLine("Please enter your plex server token:"); config.Token = Console.ReadLine(); Console.WriteLine("Please enter your plex server base url:"); config.BaseUrl = Console.ReadLine(); Console.WriteLine($"Thanks are these correct (y/n)? Token:{config.Token} Url:{config.BaseUrl}"); } while (Console.ReadLine() == "n"); var Client = new LibrarySection(config); var data = Client.GetRecentlyAddedAsync("2").Result; data.Video.ToList().ForEach(v => { Console.WriteLine($"{v.title} - {v.originallyAvailableAt.ToShortDateString()}"); Console.WriteLine(v.summary); Console.WriteLine(); }); Console.ReadLine(); }
private void loadSubSection(TreeNode _parentNode) { LibrarySection librarySection = (LibrarySection)_parentNode.Tag; if (librarySection != null) { List <LibrarySection> sections = PMSServer.librarySections(librarySection); if (!librarySection.HasTracks) { foreach (LibrarySection section in sections) { TreeNode tn = _parentNode.Nodes.Add(section.Key, section.Title); tn.Tag = section; } } } }
private void addTracksFromList(IEnumerable <DataGridViewRow> _tracks, bool _append, string _confirmMessage = "") { Playlist playlist = selectedPlaylist; if (playlist != null && _tracks != null && _tracks.Count() > 0 && (String.IsNullOrEmpty(_confirmMessage) || MessageBox.Show(String.Format("{0} will be added to the selected playlist!", _confirmMessage), "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)) { int atPosition = 0; string firstKey = null; if (!_append && gvSinglePlayList.SelectedRows.Count == 1) { Track track = gvSinglePlayList.SelectedRows[0].DataBoundItem as Track; if (track != null) { atPosition = track.Index; } } bool trackAdded; int added = 0; foreach (DataGridViewRow row in _tracks.OrderBy(r => r.Index)) { LibrarySection section = row.DataBoundItem as LibrarySection; if (section != null) { logMessage(playlistManager.addTrack(playlist.Key, section.Key, section.TrackType, atPosition, out trackAdded)); if (trackAdded) { firstKey = firstKey ?? section.Key; added++; if (atPosition > 0) { atPosition++; } } } } logMessage(String.Format("{0} tracks added to the playlist", added)); if (added > 0) { // Reload the playlist loadSinglePlaylist(playlist, firstKey, true); gvPlaylists.Refresh(); } } }
public bool matchOnTitle(ImportEntry _singleEntry, bool _checkAll) { bool anyMatched = false; var entries = from entry in m_importFile.Entries where ((_checkAll || !entry.Matched) && !String.IsNullOrEmpty(entry.Title)) && (_singleEntry == null || entry == _singleEntry) select entry; string baseMessage = "Find matches based on title.... "; progressMessage(baseMessage, true); foreach (ImportEntry entry in entries) { progressMessage(entry.Title, false); entry.resetMatches(false); foreach (MainSection mainSection in m_mainSections) { SearchSection searchSection = mainSection.TitleSearchSection(); LibrarySection librarySection = (searchSection != null) ? searchSection.createFromSearch(entry.Title) : null; if (librarySection != null) { librarySection.IsMusic = mainSection.IsMusic; var tracks = from track in PMSServer.getSectionElements(librarySection, false) select track; foreach (XElement trackElement in tracks) { if (entry.AddMatch(new MatchEntry(mainSection, trackElement))) { anyMatched = true; } } } } entry.CheckBestMatch(); } progressMessage("", true); return(anyMatched); }
private void tvServerSection_AfterSelect(object sender, TreeViewEventArgs e) { gvServerTrack.DataSource = null; if (e.Node != null && e.Node.Tag != null) { LibrarySection librarySection = e.Node.Tag as LibrarySection; if (librarySection != null) { if (!librarySection.HasTracks && e.Node.Nodes.Count == 0) { loadSubSection(e.Node); e.Node.Expand(); } if (librarySection.HasTracks) { gvServerTrack.DataSource = PMSServer.librarySections(librarySection); } } } enableServerSectionCommands(); }
public override async Task <ObservableCollection <AActivityFeedItem> > GetActivityFeed(string username, int paginationIndex, IProgress <APIProgressReport> progress) { if (string.IsNullOrWhiteSpace(username)) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "Please enter a Username", APIResponse.Failed)); } return(new ObservableCollection <AActivityFeedItem>()); } HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, Service.CreateAPIServiceUri("/users/" + username + "/feed?page=" + paginationIndex)); HttpResponseMessage response = await APIWebClient.MakeAPICall(requestMessage); if (response.IsSuccessStatusCode) { string responseAsString = await response.Content.ReadAsStringAsync(); if (progress != null) { progress.Report(new APIProgressReport(50.0, "Recieved Activity Feed From Server", APIResponse.ContinuingExecution)); } JObject o = JObject.Parse("{\"status_feed\":" + responseAsString + "}"); StoryObjectListHummingbirdV1 activityFeedRaw = JsonConvert.DeserializeObject <StoryObjectListHummingbirdV1>(o.ToString()); ObservableCollection <AActivityFeedItem> convertedActivityFeed = new ObservableCollection <AActivityFeedItem>(); foreach (var aFO in activityFeedRaw.status_feed) { string tts = aFO.updated_at.Substring(0, aFO.updated_at.Length - 1); string[] tS = tts.Split('T'); UserInfo user = new UserInfo(); DateTime timestamp; if (!DateTime.TryParse(tts, out timestamp)) { timestamp = DateTime.MinValue; } if (aFO.story_type == "comment") { user.Username = aFO.poster.name; user.AvatarUrl = new Uri(aFO.poster.avatar, UriKind.Absolute); convertedActivityFeed.Add(new ActivityFeedComment(user, aFO.substories[0].comment, timestamp)); } else if (aFO.story_type == "media_story") { user.Username = aFO.user.name; user.AvatarUrl = new Uri(aFO.user.avatar, UriKind.Absolute); string intelligibleString = ""; if (aFO.substories[0].substory_type == "watchlist_status_update") { LibrarySection librarySection = Converters.LibrarySectionConverter.StringToLibrarySection(aFO.substories[0].new_status); intelligibleString = user.Username + " " + Converters.LibrarySectionConverter.LibrarySectionToIntelligableStatusString(librarySection); } else if (aFO.substories[0].substory_type == "watched_episode") { intelligibleString = user.Username + " watched episode " + aFO.substories[0].episode_number; } ServiceID mediaID = new ServiceID(ServiceName.Hummingbird, MediaType.Anime, aFO.media.slug); Uri activityFeedImage = new Uri(aFO.media.cover_image, UriKind.Absolute); convertedActivityFeed.Add(new ActivityFeedMediaUpdate(user, mediaID, activityFeedImage, aFO.media.title, intelligibleString, timestamp)); } } if (progress != null) { progress.Report(new APIProgressReport(100.0, "Converted Successfully", APIResponse.Successful, convertedActivityFeed, activityFeedRaw)); } return(convertedActivityFeed); } if (progress != null) { progress.Report(new APIProgressReport(100.0, "API Call wasn't successul", APIResponse.Failed)); } return(new ObservableCollection <AActivityFeedItem>()); }
public void SetLibrarySectionWithoutNotify(LibrarySection section) { m_section = section; }
public override async Task <List <LibraryObject> > GetAnimeLibrary(string username, LibrarySection section, IProgress <APIProgressReport> progress) { if (string.IsNullOrWhiteSpace(username)) { if (progress != null) { progress.Report(new APIProgressReport(100.0, "Please enter a Username", APIResponse.Failed)); } return(new List <LibraryObject>()); } string statusString = Converters.LibrarySectionConverter.LibrarySectionToString(section); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, Service.CreateAPIServiceUri("/users/" + username + "/library?status=" + statusString)); HttpResponseMessage response = await APIWebClient.MakeAPICall(requestMessage); if (response.IsSuccessStatusCode) { string responseAsString = await response.Content.ReadAsStringAsync(); if (progress != null) { progress.Report(new APIProgressReport(50.0, "Recieved LibraryObjects From Server", APIResponse.ContinuingExecution)); } JObject o = JObject.Parse("{\"library\":" + responseAsString + "}"); LibraryObjectListHummingbirdV1 hummingbirdLibraryObjects = JsonConvert.DeserializeObject <LibraryObjectListHummingbirdV1>(o.ToString()); List <LibraryObject> convertedLibraryObjects = new List <LibraryObject>(); foreach (var libraryObject in hummingbirdLibraryObjects.library) { convertedLibraryObjects.Add((LibraryObject)libraryObject); } if (progress != null) { progress.Report(new APIProgressReport(100.0, "Converted Successfully", APIResponse.Successful, convertedLibraryObjects, hummingbirdLibraryObjects)); } return(convertedLibraryObjects); } if (progress != null) { progress.Report(new APIProgressReport(100.0, "API Call wasn't successul", APIResponse.Failed)); } return(new List <LibraryObject>()); }
public abstract Task <List <LibraryObject> > GetAnimeLibrary(string username, LibrarySection section, IProgress <APIProgressReport> progress);