Esempio n. 1
0
        /// <summary>
        /// 获取文件下载地址
        /// </summary>
        /// <param name="FileID"></param>
        /// <param name="FolderID"></param>
        /// <returns></returns>
        public static string GetFileDownUrl(int FileID, int FolderID)
        {
            if (!Directory.Exists(PublicConfig.CacheDir))
            {
                Directory.CreateDirectory(PublicConfig.CacheDir);
            }

            string CachePath = $"{PublicConfig.CacheDir}\\floder{NewC.Get_MD5(FileID.ToString(), false)}";

            if (File.Exists(CachePath))
            {
                return(File.ReadAllText(CachePath));
            }
            for (int page = 1; page <= 11; page++)
            {
                string Data = NewC.GET_HTTP(PublicConfig.File.GetUserDownUrl.Replace("{skip}", ((page - 1) * 100).ToString()).Replace("{folderid}", FolderID.ToString()), PublicConfig.Cookie, false);
                if (Data == "")
                {
                    return(FileID.ToString());
                }
                Dictionary <string, object> Dic = JsonToDictionary.JSONToObject <Dictionary <string, object> >(Data);
                ArrayList AL = (ArrayList)Dic["aaData"];
                foreach (ArrayList item in AL)
                {
                    if (item[1].ToString().Contains(FileID.ToString()))
                    {
                        string Url = NewC.GetString(item[1].ToString(), "href=\"", "\">", false, 0);
                        File.WriteAllText(CachePath, Url);
                        return(Url);
                    }
                }
            }
            return(FileID.ToString());
        }
Esempio n. 2
0
 void Thread_Start()
 {
     try {
         string UpUrl    = "";
         int    FolderID = Folder.GetFolderID(_FolderName);
         string Html     = NewC.GET_HTTP(PublicConfig.File.GetUpUrl.Replace("{folderid}", FolderID.ToString()), PublicConfig.Cookie, false);
         UpUrl = NewC.GetString(Html, "initUpload('", "',", false, 0);
         FileInfo Info = new FileInfo(_FilePath);
         string   Name = (_SaveName == "" ? Info.Name : _SaveName);
         Name = FilterName(Name);
         string Data = _UpFile(UpUrl, _FilePath, Name, Info.Length);
         DownUrl = GetFileDownUrl(Convert.ToInt32(Data), FolderID);
     }
     catch { }
     IsComplete = true;
 }
Esempio n. 3
0
        /// <summary>
        /// 通过文件名在指定文件夹中寻找文件
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public static string SearchFile(string FolderName, string Key, long FileLength, out string FileName)
        {
            FileName = "";
            double FileSizeMB = Convert.ToDouble(((double)FileLength / 1024 / 1024).ToString("0.00"));
            int    ID         = GetFolderID(FolderName);

            if (ID > 0)
            {
                string Data = NewC.GET_HTTP(PublicConfig.Folder.SearchUrl.Replace("{key}", Key).Replace("{folderid}", ID.ToString()), PublicConfig.Cookie, false);
                if (Data == "")
                {
                    return("");
                }

                Dictionary <string, object> Dic = JsonToDictionary.JSONToObject <Dictionary <string, object> >(Data);
                ArrayList AL = (ArrayList)Dic["aaData"];
                foreach (ArrayList item in AL)
                {
                    double Size = FileSizeMB;
                    try { Size = Convert.ToDouble(item[2].ToString().Replace("MB", "").Trim()); }
                    catch { }

                    if (FileSizeMB > Size)
                    {
                        if (FileSizeMB - Size > 1)
                        {
                            continue;
                        }
                    }
                    else if (Size - FileSizeMB > 1)
                    {
                        continue;
                    }

                    string          Url   = NewC.GetString(item[1].ToString(), "href=\"", "\">", false, 0);
                    MatchCollection Match = Regex.Matches(item[1].ToString(), @"<a.*?>(.*?)</a>", RegexOptions.IgnoreCase);
                    if (Match.Count > 0)
                    {
                        FileName = Match[0].Groups[1].ToString();
                    }
                    return(Url);
                }
            }
            return("");
        }
Esempio n. 4
0
        /// <summary>
        /// 通过文件名获取文件ID
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public static int GetFolderID(string Name)
        {
            if (!Directory.Exists(PublicConfig.CacheDir))
            {
                Directory.CreateDirectory(PublicConfig.CacheDir);
            }

            string CachePath = $"{PublicConfig.CacheDir}\\floder{NewC.Get_MD5(Name + PublicConfig.Username, false)}";

            if (File.Exists(CachePath))
            {
                return(Convert.ToInt32(File.ReadAllText(CachePath)));
            }
            for (int page = 1; page <= 11; page++)
            {
                string Data = NewC.GET_HTTP(PublicConfig.Folder.ListUrl.Replace("{skip}", ((page - 1) * 100).ToString()), PublicConfig.Cookie, false);
                if (Data == "")
                {
                    return(0);
                }
                Dictionary <string, object> Dic = JsonToDictionary.JSONToObject <Dictionary <string, object> >(Data);
                ArrayList AL = (ArrayList)Dic["aaData"];
                foreach (ArrayList item in AL)
                {
                    if (item[1].ToString().Contains(Name))
                    {
                        string ID    = NewC.GetString(item[1].ToString(), "folder_id-", "\"", false, 0);
                        int    OutID = 0;
                        if (!int.TryParse(ID, out OutID))
                        {
                            ID = NewC.GetString(item[0].ToString(), "value=\"", "\" ", false, 0);
                        }
                        int.TryParse(ID, out OutID);
                        if (OutID > 0)
                        {
                            File.WriteAllText(CachePath, OutID.ToString());
                        }
                        return(OutID);
                    }
                }
            }
            return(0);
        }