예제 #1
0
 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 = QTOM.MapObject(queryResults);
   return CTM;
 }
예제 #2
0
 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();
 }
예제 #3
0
 private 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))
     {
       request.CatalogRequest(requestUrl, "GET");
     }
       }
       catch (Exception ex)
       {
     System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
     System.Windows.Forms.MessageBox.Show("error loading catalog " + ex.Message);
     // return;
       }
 }
예제 #4
0
        private void btnAuthRequest_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            // get account access request data
            NetflixRequest request = new NetflixRequest(consumerKey, consumerSecret);
            string response;
            try
            {
                response = request.SignedRequestString(Constants.RequestUrl);
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }

            // parse the response data items
            authManager.ParseResponse(response, authItems);

            // build the access request string
            string requestUrl = HttpUtility.UrlDecode((string)authItems["login_url"]) + "&";
            // if you wish to specify a callback  URL, you can include it here...
            //	requestUrl += "oauth_callback=my_callback_url=" + callbackUrl + "&";
            requestUrl += "oauth_consumer_key=" + consumerKey + "&" +
                        "application_name=" + authItems["application_name"];
            Cursor.Current = Cursors.Default;

            // launch a Web browser using the constructed access request
            frmBrowserPopup dlg = new frmBrowserPopup();
            dlg.Url = requestUrl;
            dlg.ShowDialog();

            // can now proceed to obtaining the account access
            btnGetAccess.Enabled = true;
        }
예제 #5
0
        private void btnGetAccess_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            NetflixRequest request = new NetflixRequest(consumerKey, consumerSecret,
                                                        (string)authItems["oauth_token"],
                                                        (string)authItems["oauth_token_secret"]);
            string response;
            try
            {
                response = request.ProtectedRequest(Constants.AccessUrl);
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            // save the account authorization information that was returned
            if (!authManager.SaveAuthorization(response))
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Authorization storage request failed!");
                return;
            }

            // we should now have access to the account, set the form controls appropriately
            SetAuthState(authManager.Authorized);
            Cursor.Current = Cursors.Default;
        }