public async Task<List<CatalogTitleModel>> RefreshNetlixMyList() { List<CatalogTitleModel> CTM = new List<CatalogTitleModel>(); NetflixRequest request = new NetflixRequest(NetflixConfig.ConsumerKey, NetflixConfig.ConsumerSecret, _auth.Token, _auth.Secret); // override the default of 25 results - 100 is the max allowed request.AddQueryParameter("max_results", "100"); string requestUrl = Constants.baseAPIUrl + _auth.UserID + "/queues/instant/available"; XmlDocument xDoc; try { xDoc = await request.ProtectedRequestXml(requestUrl, "GET"); } catch (Exception ex) { // System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; // System.Windows.Forms.MessageBox.Show("error loading queue " + ex.Message); return null; } QueueTitleObjectMap QTOM = new QueueTitleObjectMap(); LinqToXmlQuery LXQ = new LinqToXmlQuery(); var queryResults = LXQ.QueryData(xDoc); CTM = await Task.Run(() => QTOM.MapObject(queryResults)); return CTM; }
private async Task parseLink(XElement E) { if (E.ToString().Contains("synopsis")) { try { NetflixRequest req = new NetflixRequest(NetflixConfig.ConsumerKey, NetflixConfig.ConsumerSecret, _auth.Token, _auth.Secret); string href = E.FirstAttribute.ToString().Remove(0, 6); href = href.Remove(href.Length - 1, 1); string result = req.ProtectedRequest(href); int endIndex = result.IndexOf(']'); int startIndex = result.LastIndexOf('[') + 1; CT.Synopsis = result.Substring(startIndex, endIndex - startIndex); } catch (Exception ex) { } } //Add Later if necessary links included links to synopsis and similars etc... }
private async void LoadCatalog() { // string requestUrl = "http://api-public.netflix.com/catalog/titles/streaming?v=2.0&expand=@seasons,@episodes,@awards"; string requestUrl = "http://api-public.netflix.com/catalog/titles/streaming"; NetflixRequest request = new NetflixRequest(NetflixConfig.ConsumerKey, NetflixConfig.ConsumerSecret, _auth.Token, _auth.Secret); try { //Check if file exists if not make request to retrieve full streaming catalog string filePath = "c:\\temp\\netflixStreamingCatalog.xml"; if (!File.Exists(filePath) || File.GetCreationTime(filePath) < DateTime.Now.AddDays(-7)) { if (File.Exists(filePath)) File.Delete(filePath); Messenger.Default.Send("Updating", "LoadStatus"); await Task.Run(() => request.CatalogRequest(requestUrl, "GET")); } Messenger.Default.Send("Successful", "LoadStatus"); } catch (Exception ex) { Messenger.Default.Send("UnSuccessful", "LoadStatus"); } }
private async void UpdateInstantQueue(string TitleID, int Position, int EOQ, string Action) { // prepare update request NetflixRequest request = new NetflixRequest(NetflixConfig.ConsumerKey, NetflixConfig.ConsumerSecret, _auth.Token, _auth.Secret); string requestUrl = Constants.baseAPIUrl + _auth.UserID + "/queues/instant"; request.AddQueryParameter("etag", _etag); string titleRef = "http://api-public.netflix.com/catalog/titles/movies/" + TitleID; request.AddQueryParameter("title_ref", titleRef); // dispatch on action-specific operations switch (Action) { case "POST": if (Position != 999) { // add title at requested position request.AddQueryParameter("position", Position.ToString()); } // For an Add, the new title is just placed at the // end of the queue if no position is specified. break; case "MOVE": if (Position != 999) { // move title to requested position request.AddQueryParameter("position", Position.ToString()); } else { // For a Move if you don't include the position the // update just leaves it where it is, so we have to tell it // specifically to move it to the end of the queue. request.AddQueryParameter("position", EOQ.ToString()); } Action = "POST"; break; case "DELETE": // for Delete, you have to specify the exact queue name requestUrl += "/available/" + TitleID; break; } try { XmlDocument xDoc; xDoc = await request.ProtectedRequestXml(requestUrl, Action); } catch (Exception ex) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; System.Windows.Forms.MessageBox.Show(ex.Message); return; } // reload to show changes (does its own wait cursor) //RefreshNetlixMyList(); }