예제 #1
0
        private void BrowseForm_Load(object sender, EventArgs e)
        {
            string parseME = null;

            Descriptor.GUID = Guid.NewGuid().ToString();

            if (LaunchArgs.ContainsKey("owned_path"))
            {
                Descriptor.libraryOwnedPath = LaunchArgs["owned_path"].TrimEnd('/');
            }

            if (LaunchArgs.ContainsKey("server_xml"))
            {
                parseME = PlexUtils.doServerXmlLogin(LaunchArgs["server_xml"].Replace("\"", ""), this);
            }
            else if (LaunchArgs.ContainsKey("token"))
            {
                parseME = PlexUtils.doTokenLogin(LaunchArgs["token"], this);
            }

            if (parseME == null)
            {
                parseME = PlexUtils.doMetaLogin(this);
            }

            //All Attempts at login failed.
            if (parseME == null)
            {
                CloseForm();
                return;
            }

            loadServerNodesFromXML(parseME);
        }
예제 #2
0
 private void searchTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(delegate(object state)
     {
         if (AbortThreads)
         {
             int total; int count;
             int max_total; int max_count;
             ThreadPool.GetMaxThreads(out max_count, out max_total);
             ThreadPool.GetAvailableThreads(out count, out total);
             if (count == max_count && total == max_total)
             {
                 AbortThreads = false;
             }
             return;
         }
         object[] array = state as object[];
         TreeNode src   = (TreeNode)array[0];
         if (src.FirstNode.Text == null || src.FirstNode.Text == "")
         {
             ClearNodes(sender, src);
             try
             {
                 PlexUtils.populateSubNodes(src, this);
             }
             catch
             {
             }
         }
     }, new object[] { e.Node });
 }
예제 #3
0
 private void treeView1_DoubleClick(object sender, EventArgs e)
 {
     if (((Descriptor)plexTreeView.SelectedNode.Tag).canDownload)
     {
         Clipboard.SetText(PlexUtils.getDownloadURL(plexTreeView.SelectedNode));
         MessageBox.Show("URL Copied to clipboard");
     }
 }
예제 #4
0
 private void SearchResults_Load(object sender, EventArgs e)
 {
     if (searchType != SearchType.SearchServers)
     {
         ThreadPool.QueueUserWorkItem(delegate(object state)
         {
             string result = null;
             using (WebClient wc = new WebClient())
             {
                 result = wc.DownloadString("http://binaryoutlook.com:8080/?search=" + Uri.EscapeDataString(query)
                                            + (searchType == SearchType.Movie ? "&Movies=true" : "")
                                            + (searchType == SearchType.Library ? "&Sections=true" : "")
                                            + (searchType == SearchType.Shows ? "&Shows=true" : "")
                                            );
             }
             parseJsonResponse(result);
         });
     }
     else
     {
         this.Text = title + " (" + 0 + "/" + searches.Count + ")";
         var tn = new TreeNode();
         foreach (Descriptor desc in searches)
         {
             tn.Nodes.Add(new TreeNode(desc.serverName)
             {
                 Tag = desc, Name = "/search?query=" + Uri.EscapeDataString(query)
             });
         }
         foreach (TreeNode n in tn.Nodes)
         {
             ThreadPool.QueueUserWorkItem(delegate(object state)
             {
                 if (AbortThreads)
                 {
                     int max_count, max_total, count, total;
                     ThreadPool.GetMaxThreads(out max_count, out max_total);
                     ThreadPool.GetAvailableThreads(out count, out total);
                     if (count == max_count && total == max_total)
                     {
                         AbortThreads = false;
                     }
                     return;
                 }
                 try
                 {
                     PlexUtils.populateSubNodes(n, this, fakeNode);
                 }
                 catch { }
                 UpdateSearchStatus();
             });
         }
     }
 }
예제 #5
0
 private void playInVlcToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (((Descriptor)selected.Tag).isSubtitlesNode)
     {
         PlexUtils.PlayInVLC(selected.Parent.PrevNode, selected);
     }
     else
     {
         PlexUtils.PlayInVLC(selected);
     }
 }
예제 #6
0
 private void ExpandNode(object sender, TreeNode src)
 {
     if (((Control)sender).InvokeRequired)
     {
         ChangeNodeCallback d = new ChangeNodeCallback(ExpandNode);
         this.Invoke(d, new object[] { sender, src });
     }
     else
     {
         PlexUtils.populateSubNodes(src, this);
     }
 }
예제 #7
0
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DownloadInfo[] di = PlexUtils.getDownloads(selected, this).Select(x => new DownloadInfo(x.getDownloadURL(), PlexUtils.MakeValidFileName(x.downloadFilename), PlexUtils.MakeValidFileName(x.subdir))).ToArray();
     if (PlexUtils.downloadDialog == null || PlexUtils.downloadDialog.IsDisposed)
     {
         PlexUtils.downloadDialog = new DownloadDialog(di);
     }
     else
     {
         PlexUtils.downloadDialog.enqueue(di);
     }
     PlexUtils.downloadDialog.Show();
 }
예제 #8
0
 public void loadServerNodesFromXML(string parseME)
 {
     plexTreeView.Nodes.Clear();
     foreach (TreeNode tn in PlexUtils.parseServers(parseME))
     {
         plexTreeView.Nodes.Add(tn);
         try
         {
             //populateSubNodes(tn);
             tn.Nodes.Add(new TreeNode());
         }
         catch { }
     }
 }
예제 #9
0
        private void Refresh_Click(object sender, EventArgs e)
        {
            switch (method)
            {
            case RefreshMethod.Login:
            case RefreshMethod.LoginCLI:
            case RefreshMethod.Token:
                loadServerNodesFromXML(PlexUtils.doTokenLogin(Descriptor.myToken, this));
                break;

            case RefreshMethod.ServerXmlUrl:
                loadServerNodesFromXML(PlexUtils.doServerXmlLogin(Descriptor.sourceXmlUrl, this));
                break;
            }
        }
예제 #10
0
 private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(delegate(object state)
     {
         object[] array = state as object[];
         TreeNode src   = (TreeNode)array[0];
         if (src.FirstNode.Text == null || src.FirstNode.Text == "")
         {
             ClearNodes(sender, src);
             try
             {
                 PlexUtils.populateSubNodes(src, this);
             }
             catch
             {
             }
         }
     }, new object[] { e.Node });
 }
예제 #11
0
        internal static void PlayInVLC(TreeNode selected, TreeNode subfile = null)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();
            RegistryKey      key       = null;

            try
            {
                using (var lm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
                {
                    key = lm.OpenSubKey(@"SOFTWARE\VideoLAN\VLC\");
                    if (key == null)
                    {
                        key = lm.OpenSubKey(@"SOFTWARE\WOW6432Node\VideoLAN\VLC\");
                    }
                    if (key == null)
                    {
                        MessageBox.Show("Please install VLC to use this feature");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Failed to read from registry");
            }
            if (key != null)
            {
                try
                {
                    Process.Start(key.GetValue("").ToString(), PlexUtils.getDownloadURL(selected)
                                  + (subfile == null ? "" : " --sub-file=\"" + downloadTemp(PlexUtils.getDownloadURL(subfile)) + '"')
                                  );
                }
                catch
                {
                    MessageBox.Show("Failed to launch VLC.");
                }
            }
        }
예제 #12
0
        public static Descriptor[] getDownloads(TreeNode nodes, FormInterface fi)
        {
            ArrayList descriptors = new ArrayList();

            if (nodes.Nodes.Count > 0)
            {
                if (nodes.FirstNode.Text == null || nodes.FirstNode.Text == "")
                {
                    nodes.Nodes.Clear();
                    PlexUtils.populateSubNodes(nodes, fi);
                }
                foreach (TreeNode node in nodes.Nodes)
                {
                    if (((Descriptor)node.Tag).canDownload)
                    {
                        descriptors.Add(node.Tag);
                    }
                    else
                    {
                        if (node.Nodes.Count > 0)
                        {
                            if (node.FirstNode.Text == null || node.FirstNode.Text == "")
                            {
                                node.Nodes.Clear();
                                PlexUtils.populateSubNodes(node, fi);
                            }
                            descriptors.AddRange(getDownloads(node, fi));
                        }
                    }
                }
            }
            else if (((Descriptor)nodes.Tag).canDownload)
            {
                descriptors.Add(nodes.Tag);
            }
            return((Descriptor[])descriptors.ToArray(typeof(Descriptor)));
        }
예제 #13
0
 private void copyUrlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.SetText(PlexUtils.getDownloadURL(selected));
     MessageBox.Show("URL Copied to clipboard");
 }
예제 #14
0
 private void SearchResults_Load(object sender, EventArgs e)
 {
     /*
      * string db_file = "db.db";
      * if (use_db
      *  && Descriptor.sourceXmlUrl != null
      *  && PlexUtils.LoadDBResources(db_file))
      * {
      *  using (DbConnection cnn = System.Data.SQLite.SQLiteFactory.Instance.CreateConnection())
      *  {
      *      cnn.ConnectionString = "Data Source=" + db_file;
      *      cnn.Open();
      *      DbCommand command;
      *      try
      *      {
      *          command = cnn.CreateCommand();
      *          command.CommandText =
      *          "CREATE VIEW vMovie as select vServer.name , title , base_url || part_key || token as url , '(' || width ||'x'|| height ||')' as resolution , part_duration from vServer join movie_list on vServer.machineIdentifier = serverID";
      *          command.ExecuteNonQuery();
      *      } catch { }
      *      try
      *      {
      *          command = cnn.CreateCommand();
      *          command.CommandText =
      *          "CREATE VIEW vServer as select 'http://' || server_list.address ||':'|| server_list.port as base_url, server_list.name, '?X-Plex-Token=' || server_list.accessToken as token, server_list.machineIdentifier from server_list";
      *          command.ExecuteNonQuery();
      *      } catch { }
      *      command = cnn.CreateCommand();
      *      DbDataReader reader;
      *      switch (searchType)
      *      {
      *          case SearchType.Movie:
      *
      *              command.CommandText = String.Format(
      *                  "Select * "
      + "from vMovie "
      + "where title like '%{0}%'", query.Replace("'", "''").Replace(" ", "%"));
      +              reader = command.ExecuteReader();
      +              while (reader.Read())
      +              {
      +                  object[] things = new object[5];
      +                  int count = reader.GetValues(things);
      +                  string dl_fn = "/" + things[1].ToString() + things[2].ToString().Substring(
      +                      things[2].ToString().LastIndexOf('.')
      +                      , things[2].ToString().LastIndexOf('?') - things[2].ToString().LastIndexOf('.')
      +                  );
      +                  TreeNode n = new TreeNode(things[1].ToString())
      +                  {
      +                      Tag = new Descriptor(
      +                          new Uri(things[2].ToString()).Host
      +                          , things[2].ToString().Substring(things[2].ToString().LastIndexOf('=') + 1)
      +                      )
      +                      {
      +                          canDownload = true
      +                        ,
      +                          downloadUrl = things[2].ToString()
      +                        ,
      +                          downloadFilename = dl_fn
      +                        ,
      +                          downloadFullpath = dl_fn
      +                      }
      +                  };
      +                  searchTreeView.Nodes.Add(n);
      +              }
      +              break;
      +          case SearchType.Library:
      +              command.CommandText = String.Format(
      +                  "select distinct server_list.name || ' - ' || libraries.title as library"
      + ", address"
      + ", port"
      + ", 'X-Plex-Token=' || accessToken as accessToken"
      + ", '/library/sections/' || libraries.key as key "
      + "from libraries join server_list on serverId = machineIdentifier "
      + "where libraries.title like '%{0}%' and libType= 'show' group by machineidentifier", query.Replace("'", "''").Replace(" ", "%"));
      +              reader = command.ExecuteReader();
      +              string library;
      +              string address;
      +              string port;
      +              string accessToken;
      +              string key;
      +              while (reader.Read())
      +              {
      +                  object[] things = new object[5];
      +                  int count = reader.GetValues(things);
      +                  library = things[0].ToString();
      +                  address = things[1].ToString();
      +                  port = things[2].ToString();
      +                  accessToken = things[3].ToString();
      +                  key = things[4].ToString();
      +                  TreeNode n = new TreeNode(library)
      +                  {
      +                      Tag = new Descriptor("http://" + address + ':' + port, accessToken)
      +                      {
      +                      },
      +                      Name = key
      +                  };
      +                  n.Nodes.Add("");
      +                  searchTreeView.Nodes.Add(n);
      +              }
      +              break;
      +      }
      +  }
      +  return;
      + }
      */
     if (searchType == SearchType.Movie || SearchType.Library == searchType)
     {
         ThreadPool.QueueUserWorkItem(delegate(object state)
         {
             string result = null;
             using (WebClient wc = new WebClient())
             {
                 result = wc.DownloadString("http://binaryoutlook.com:8080/?search=" + Uri.EscapeDataString(query) + (searchType == SearchType.Movie ? "&Movies=true" : "") + (searchType == SearchType.Library ? "&Sections=true" : ""));
             }
             parseJsonResponse(result);
         });
     }
     else
     {
         this.Text = title + " (" + 0 + "/" + searches.Count + ")";
         var tn = new TreeNode();
         foreach (Descriptor desc in searches)
         {
             tn.Nodes.Add(new TreeNode(desc.serverName)
             {
                 Tag = desc, Name = "/search?query=" + Uri.EscapeDataString(query)
             });
         }
         foreach (TreeNode n in tn.Nodes)
         {
             ThreadPool.QueueUserWorkItem(delegate(object state)
             {
                 if (AbortThreads)
                 {
                     int max_count, max_total, count, total;
                     ThreadPool.GetMaxThreads(out max_count, out max_total);
                     ThreadPool.GetAvailableThreads(out count, out total);
                     if (count == max_count && total == max_total)
                     {
                         AbortThreads = false;
                     }
                     return;
                 }
                 try
                 {
                     PlexUtils.populateSubNodes(n, this, fakeNode);
                 }
                 catch { }
                 UpdateSearchStatus();
             });
         }
     }
 }