Advertisement
iWinterHD7s

Unsubscriber

Jul 1st, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. public void UnSubUsers()
  2.       {
  3.             string feedUrl = "http://gdata.youtube.com/feeds/api/users/" + username.Text + "/subscriptions";
  4.             YouTubeQuery query = new YouTubeQuery(feedUrl);
  5.             subFeed = service.GetSubscriptions(query);
  6.             YouTubeRequestSettings yts = new YouTubeRequestSettings("Unsubscriber", DEVKEY, username.Text, password.Text);
  7.             YouTubeRequest request = new YouTubeRequest(yts);
  8.             int i = 0;
  9.             int x = 0;
  10.             x = (listBox1.Items.Count);
  11.             for (i=0;i<x ;i++ )
  12.             {
  13.                 string uname = listBox1.Items[i].ToString();
  14.                 uname=uname.Substring(42);
  15.                 uname = uname.Remove(uname.LastIndexOf("/"));
  16.                 Subscription s = new Subscription();
  17.                 s.Type = SubscriptionEntry.SubscriptionType.channel;
  18.                 s.UserName = uname;
  19.                 //MessageBox.Show(uname); //Displays the username so that we know if it is correct
  20.                 try
  21.                 {
  22.                     s.AtomEntry.EditUri = "http://gdata.youtube.com/feeds/api/users/" + username.Text + "/subscriptions";
  23.                     s.SubscriptionEntry.EditUri = "http://gdata.youtube.com/feeds/api/users/" + username.Text + "/subscriptions";
  24.                     request.Delete(s);
  25.                 }
  26.                 catch (ArgumentNullException e)
  27.                 {
  28.                     MessageBox.Show(e.ToString(), "Error");
  29.                 }
  30.                 catch (GDataRequestException e)
  31.                 {
  32.                     MessageBox.Show(e.ToString(), "Error");
  33.                 }
  34.             }
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement