コード例 #1
0
        public BTDictionary GetTorrentDict(string torrentFile)
        {
            // find dictionary for the specified torrent file

            BTItem it = ResumeDat.GetDict().GetItem(torrentFile, true);

            if ((it is null) || (it.Type != BTChunk.kDictionary))
            {
                return(null);
            }

            BTDictionary dict = (BTDictionary)(it);

            return(dict);
        }
コード例 #2
0
ファイル: uTorrent.cs プロジェクト: MichielCuijpers/tvrename
        private void RefreshResumeDat()
        {
            if (!this.CheckResumeDatPath())
            {
                return;
            }

            List <string> checkedItems = new List <String>();

            foreach (string torrent in this.lbUTTorrents.CheckedItems)
            {
                checkedItems.Add(torrent);
            }

            this.lbUTTorrents.Items.Clear();
            // open resume.dat file, fill checked list box with torrents available to choose from

            string file = TVSettings.Instance.ResumeDatPath;

            if (!File.Exists(file))
            {
                return;
            }
            BEncodeLoader bel       = new BEncodeLoader();
            BTFile        resumeDat = bel.Load(file);

            if (resumeDat == null)
            {
                return;
            }
            BTDictionary dict = resumeDat.GetDict();

            for (int i = 0; i < dict.Items.Count; i++)
            {
                BTItem it = dict.Items[i];
                if (it.Type == BTChunk.kDictionaryItem)
                {
                    BTDictionaryItem d2 = (BTDictionaryItem)(it);
                    if ((d2.Key != ".fileguard") && (d2.Data.Type == BTChunk.kDictionary))
                    {
                        this.lbUTTorrents.Items.Add(d2.Key);
                    }
                }
            }

            foreach (string torrent in checkedItems)
            {
                for (int i = 0; i < this.lbUTTorrents.Items.Count; i++)
                {
                    if (this.lbUTTorrents.Items[i].ToString() == torrent)
                    {
                        this.lbUTTorrents.SetItemChecked(i, true);
                    }
                }
            }
        }
コード例 #3
0
ファイル: uTorrent.cs プロジェクト: bravesoftdz/tvrename
        private void SetupResumeDats()
        {
            List <string> checkedItems = new List <string>();

            foreach (string torrent in lbUTTorrents.CheckedItems)
            {
                checkedItems.Add(torrent);
            }

            lbUTTorrents.Items.Clear();

            string resume_dir = Path.Combine(Path.GetDirectoryName(TVSettings.Instance.ResumeDatPath), "resume_dir");

            ResumeDats = new Dictionary <string, string>();

            string[] files = Directory.GetFiles(resume_dir, "*.dat");
            foreach (string file in files)
            {
                BEncodeLoader bel       = new BEncodeLoader();
                BTFile        resumeDat = bel.Load(file);
                if (resumeDat == null)
                {
                    break;
                }
                BTDictionary dict = resumeDat.GetDict();
                foreach (BTItem it in dict.Items)
                {
                    if (it.Type == BTChunk.kDictionaryItem)
                    {
                        BTDictionaryItem d2 = (BTDictionaryItem)(it);
                        if ((d2.Key != ".fileguard") && (d2.Data.Type == BTChunk.kDictionary))
                        {
                            ResumeDats.Add(Path.GetFileNameWithoutExtension(file), d2.Key);
                            lbUTTorrents.Items.Add(d2.Key);
                        }
                    }
                }
            }

            foreach (string torrent in checkedItems)
            {
                for (int i = 0; i < lbUTTorrents.Items.Count; i++)
                {
                    if (lbUTTorrents.Items[i].ToString() == torrent)
                    {
                        lbUTTorrents.SetItemChecked(i, true);
                    }
                }
            }
        }