Exemplo n.º 1
0
        protected void GetEmAll()
        {
            string url = Rbase64.Decode(Request.QueryString["Url"].UrlDecode()), path = RouteData.GetRelativePath();

            if (string.IsNullOrWhiteSpace(url))
            {
                return;
            }
            foreach (var video in Net.YouTube.Video.GetVideoFromLink(url))
            {
                var isTarget = video.Url.Equals(url, StringComparison.InvariantCultureIgnoreCase);
                Response.Write(string.Format("<details{4}><summary title=\"{3}\"><a href=\"{1}\">{0}</a>{2}</summary>",
                                             video.Title, video.Url, isTarget ? string.Empty : string.Format
                                                 (" <a href=\"?Url={0}\" target=\"_blank\">[查看相关视频]</a>", Rbase64.Encode(video.Url)),
                                             string.Format("标题:{0}{8}上传者:{1}{8}关键字:{2}{8}平均评分:{3}{8}观看次数:{4}{8}" +
                                                           "上传时间:{5}{8}时长:{6}{8}地址:{7}", video.Title, video.Author,
                                                           string.Join(", ", video.Keywords), video.AverageRating, video.ViewCount,
                                                           video.UploadTime.ToChineseString(), video.Length, video.Url, "&#10;"),
                                             isTarget ? " open" : string.Empty));
                foreach (var link in video.Downloads)
                {
                    Response.Write(string.Format("<div title=\"{1}\">{0}</div>",
                                                 link.UrlUnavailableException == null
                            ? string.Format("<a href=\"/Offline/Start/{2}?Url={0}\" target=\"_blank\">{1}</a>",
                                            Rbase64.Encode(link.GetUrl(link.Parent.Title)), link,
                                            FileHelper.Combine(path, (link.Parent.Title + link.Extension).ToValidPath()))
                            : link.ToString(), link.Properties.Replace(Environment.NewLine, "&#10;")));
                }
                Response.Write("</details>" + Environment.NewLine);
                Response.Flush();
            }
        }
Exemplo n.º 2
0
        private static void Main()
        {
            try
            {
                var lines = Rbase64.Decode(Console.ReadLine()).Split('\n');
                switch (lines[0].ToLowerInvariant())
                {
                case TaskType.OfflineDownloadTask:
                    OfflineDownload(lines[1], lines[2]);
                    break;

                case TaskType.FtpUploadTask:
                    new FtpUploadTask(lines[1]).Execute();
                    break;

                case TaskType.DecompressTask:
                    new DecompressTask(lines[1]).Execute();
                    break;

                case TaskType.CompressTask:
                    new CompressTask(lines[1]).Execute();
                    break;

                case TaskType.ConvertTask:
                    new ConvertTask(lines[1]).Execute();
                    break;

                case TaskType.CrossAppCopyTask:
                    new CrossAppCopyTask(lines[1]).Execute();
                    break;

                case TaskType.BatchMergeVATask:
                    var splitter = new[] { '\t' };
                    BatchMergeVA(lines[1], "true".Equals(lines[2], StringComparison.InvariantCultureIgnoreCase),
                                 lines[3], lines[4].Split(splitter, StringSplitOptions.RemoveEmptyEntries),
                                 lines[5].Split(splitter, StringSplitOptions.RemoveEmptyEntries));
                    break;

                default:
                    Console.WriteLine("无法识别。");
                    break;
                }
            }
            catch (Exception exc)
            {
                File.AppendAllText(@"Data\error.log", string.Format("[{0}] {1}{2}{2}", DateTime.UtcNow,
                                                                    exc.GetMessage(), Environment.NewLine));
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.GetUser().OperateTasks)
            {
                Response.StatusCode = 401;
                return;
            }
            var url          = Rbase64.Decode(Request.QueryString["Url"].UrlDecode());
            var relativePath = RouteData.GetRelativePath();

            if (!string.IsNullOrWhiteSpace(url))
            {
                OfflineDownloadTask.Create(url, relativePath);
            }
            if ("True".Equals(Request.QueryString["Redirect"], StringComparison.InvariantCultureIgnoreCase))
            {
                Response.Redirect("/Browse/" + relativePath + '/');
            }
            else
            {
                Response.Write("<script>window.opener=null;window.close();</script>");
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.GetUser().OperateTasks)
            {
                Response.StatusCode = 401;
                return;
            }
            Response.Clear();
            Response.ContentType = "application/xml";
            var result = new XElement("result");
            var path   = RouteData.GetRelativePath();

            try
            {
                GeneralTask task;
                switch (RouteData.GetRouteString("Type").ToLowerInvariant())
                {
                case "offline":
                    OfflineDownloadTask.Create(Rbase64.Decode(Request.QueryString["Url"]), path);
                    break;

                case "ftpupload":
                    result.SetAttributeValue("id", (task = new FtpUploadTask(path,
                                                                             Request.QueryString["Files"].Split('|').Select(file => file.UrlDecode()),
                                                                             Request.QueryString["Target"].UrlDecode())));
                    task.Start();
                    break;

                case "compress":
                    new CompressTask(path,
                                     Request.QueryString["Files"].Split('|').Select(file => file.UrlDecode()),
                                     Request.QueryString["BaseFolder"].UrlDecode(),
                                     Request.QueryString["CompressionLevel"]).Start();
                    break;

                case "decompress":
                    result.SetAttributeValue("id", (task = new DecompressTask
                                                               (path, Request.QueryString["Target"].UrlDecode())).ID);
                    task.Start();
                    break;

                case "convert":
                    ConvertTask.Create(path, Request.QueryString["Target"].UrlDecode(),
                                       Request.QueryString["Size"].UrlDecode(),
                                       Request.QueryString["VCodec"].UrlDecode(),
                                       Request.QueryString["ACodec"].UrlDecode(),
                                       Request.QueryString["SCodec"].UrlDecode(),
                                       Request.QueryString["AudioPath"].UrlDecode(),
                                       Request.QueryString["Start"].UrlDecode(),
                                       Request.QueryString["End"].UrlDecode()).Start();
                    break;

                case "crossappcopy":
                    result.SetAttributeValue("id", (task = new CrossAppCopyTask(
                                                        Request.QueryString["Domain"].UrlDecode(), Request.QueryString["Path"].UrlDecode(),
                                                        path, Request.QueryString["Password"].UrlDecode() ?? Request.GetPassword())));
                    task.Start();
                    break;

                case "batchmergeva":
                    TaskHelper.StartRunner(string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}", TaskType.BatchMergeVATask,
                                                         path, Request.QueryString["DeleteSource"],
                                                         Request.QueryString["VideoPattern"],
                                                         Request.QueryString["ResultPattern"],
                                                         Request.QueryString["AudioPatterns"]));
                    break;

                default:
                    throw new FormatException("无法识别的 Type!");
                }
                result.SetAttributeValue("status", "ok");
            }
            catch (Exception exc)
            {
                result.SetAttributeValue("status", "error");
                result.SetAttributeValue("message", exc.GetMessage());
            }
            Response.Write(result.ToString());
        }