private void GenerateBlogPost(string outputId, string imageCodeBlog, string linksPage, IEnumerable <string> shortenedLinks, LinksBackup linksBackup, VideoInfo videoInfo)
        {
            string blogTitle;

            if (videoInfo.Title.Contains("Tokyo Hot"))
            {
                blogTitle = string.Format("{0}", videoInfo.Title.Replace("Tokyo Hot", "Tokyo-Hot"));
            }
            else
            {
                if (videoInfo.RemoveIdDash)
                {
                    outputId = outputId.Replace("-", "");
                }

                blogTitle = videoInfo.HideId ? videoInfo.Title :
                            string.Format("[{0}] {1}", outputId, videoInfo.Title);
            }

            string linksContent = null;

            foreach (var shortenedLink in shortenedLinks)
            {
                if (string.IsNullOrEmpty(linksContent))
                {
                    linksContent = "<a href=\"" + shortenedLink + "\">" + shortenedLink + "</a>";
                }
                else
                {
                    linksContent += "<br />or<br /><a href=\"" + shortenedLink + "\">" + shortenedLink + "</a>";
                }
            }
            if (string.IsNullOrEmpty(linksContent))
            {
                linksContent = linksPage;
            }

            Blogger.AddPost(new Blogger.BlogPost(blogTitle, imageCodeBlog, linksContent, linksBackup));

            var content = blogTitle + Environment.NewLine + Environment.NewLine +
                          "<div style='text-align: center;'>" +
                          imageCodeBlog +
                          "</div>" +
                          string.Format("Download(Mega.nz, {0}) : < br />< !--more-- > ", SecondHostName) +
                          linksContent
                          + Environment.NewLine + Environment.NewLine +
                          "==" + Environment.NewLine + Environment.NewLine;

            File.AppendAllText(outputPath_blog, content);
        }
        private async Task GenerateOutput(string outputId, string fileSize, string fileFormat, string imageCode,
                                          string imageCodeBlog, string linksPage, LinksBackup linksBackup, bool isUncensored,
                                          IEnumerable <string> shortenedLinks)
        {
            var videoInfoTw = await VideoInfo.QueryVideoInfo(outputId, QueryLang.TW);

            GenerateBlogPost(outputId, imageCodeBlog, linksPage, shortenedLinks, linksBackup, videoInfoTw);

            var uncensored = isUncensored ? "無碼" : "有碼";

            string linksContent = null;

            foreach (var shortenedLink in shortenedLinks)
            {
                if (string.IsNullOrEmpty(linksContent))
                {
                    linksContent = shortenedLink;
                }
                else
                {
                    linksContent += Environment.NewLine + "or" + Environment.NewLine + shortenedLink;
                }
            }
            if (string.IsNullOrEmpty(linksContent))
            {
                linksContent = linksPage;
            }

            var title = videoInfoTw.HideId ? videoInfoTw.Title
                : string.Format("{0} ({1})", videoInfoTw.Title, outputId);

            var content = string.Format(@"{0} [{1}/{2}][多空]

[color=green][b]【影片名稱】:[/b][/color]{0}

[color=green][b]【出演女優】:[/b][/color]{5}

[color=green][b]【檔案大小】:[/b][/color]{1}

[color=green][b]【影片時間】:[/b][/color]120 Min

[color=green][b]【檔案格式】:[/b][/color]{2}

[color=green][b]【下載空間】:[/b][/color]Mega & {7}

[color=green][b]【有/無碼】:[/b][/color]{6}

[color=green][b]【圖片預覽】:[/b][/color]
{3}

[color=green][b]【檔案載點】:[/b][/color]
[hide]
{4}
[/hide]

==

", title, fileSize, fileFormat, imageCode, linksContent, videoInfoTw.Actresses, uncensored, SecondHostName);

            File.AppendAllText(outputPath_lh, content);
            File.AppendAllText(outputPath_l, content.Replace(Environment.NewLine + "[hide]", string.Empty).Replace("[/hide]" + Environment.NewLine, string.Empty));
        }
        public async Task WriteOutput(string megaLinks, string rgLinks)
        {
            string imageCode     = null;
            string imageCodeBlog = null;
            var    isUncensored  = VideoInfo.IsUncensored(id);
            var    megaBackup    = megaLinks;
            var    rgBackup      = rgLinks;

            var outputId = id;

            if (!isUncensored && !RealStreetAngels.Match(id) && !SiroutoDouga.Match(id))
            {
                outputId = id.ToUpper();
                int dash = 0;
                for (int i = 0; i < outputId.Length - 1; i++)
                {
                    if (char.IsLetter(outputId[i]))
                    {
                        if (!char.IsDigit(outputId[i + 1]))
                        {
                            continue;
                        }
                        dash = i + 1;
                    }
                }
                if (dash > 0)
                {
                    outputId = outputId.Insert(dash, "-");
                }
            }

            var flinks = new Dictionary <int, string>
            {
                { 0, ForumLinks1 },
                { 1, ForumLinks2 },
                { 2, ForumLinks3 },
                //{ 3, ForumLinks4 },
            };
            var wlinks = new Dictionary <int, string>
            {
                { 0, WebLinks1 },
                { 1, WebLinks2 },
                { 2, WebLinks3 },
                //{ 3, WebLinks4 },
            };

            if (flinks.Count(p => !string.IsNullOrEmpty(p.Value)) == 1 || wlinks.Count(p => !string.IsNullOrEmpty(p.Value)) == 1)
            {
                imageCode     = flinks.First().Value;
                imageCodeBlog = wlinks.First().Value;
            }
            else
            {
                var fIndex = imageHostIndex % flinks.Count;
                var wIndex = fIndex < flinks.Count - 1 ? fIndex + 1 : 0;

                imageCode     = flinks[fIndex];
                imageCodeBlog = wlinks[wIndex];

                if (string.IsNullOrEmpty(imageCode) || string.IsNullOrEmpty(imageCodeBlog))
                {
                    imageCode = flinks.Where(l => !string.IsNullOrEmpty(l.Value)).Select(l => l.Value).Random();
                    var imgCodeIndex = flinks.FirstOrDefault(l => l.Value == imageCode).Key;
                    imageCodeBlog = wlinks.Where(l => l.Key != imgCodeIndex && !string.IsNullOrEmpty(l.Value)).Select(l => l.Value).Random();
                }
            }

            imageHostIndex++;

            try
            {
                string filePath   = null;
                string uploadPath = null;

                foreach (var path in UploadPaths)
                {
                    if (!Directory.Exists(path))
                    {
                        continue;
                    }
                    filePath =
                        Directory.GetFiles(path, string.Format("{0}*.part*.rar", id), SearchOption.TopDirectoryOnly)
                        .FirstOrDefault();
                    if (filePath == null)
                    {
                        continue;
                    }
                    uploadPath = path;
                    break;
                }

                string fileFormat = null, fileSize = null;
                if (!string.IsNullOrEmpty(filePath) && !string.IsNullOrEmpty(uploadPath))
                {
                    fileFormat = VideoUtil.GetFileFormat(filePath);
                    fileSize   = VideoUtil.GetFileSizeGB(uploadPath, id) + "GB";
                }

                var ouoShortening = urlShortenings.First(u => u.Name == "Ouo");
                megaLinks = await ShortenFirstLink(ouoShortening, megaLinks);

                if (rgLinks.Contains("zippyshare"))
                {
                    var eraShortening = urlShortenings.First(u => u.Name == "ERA.AC");
                    rgLinks = await ShortenFirstLink(eraShortening, rgLinks);
                }

                string links1 = null, links2 = null;
                switch (rnd.Next(0, 1000) % 2)
                {
                case 0:
                    links1 = megaLinks;
                    links2 = rgLinks;
                    break;

                case 1:
                    links1 = rgLinks;
                    links2 = megaLinks;
                    break;
                }

                var content = string.Empty;
                content  = string.Format("{0}\\nor\\n{1}", links1, links2);
                content += "\\n\\nAll links are interchangeable and no password.";
                content  = content.Replace("\\n", "<br />");

                var contentBackup = string.Format("{0}\\nor\\n{1}", megaBackup, rgBackup);
                contentBackup += "\\n\\nAll links are interchangeable and no password.";
                contentBackup  = contentBackup.Replace("\\n", "<br />");

                var linksBackup = new LinksBackup
                {
                    Id    = id,
                    Links = contentBackup,
                };

                var linksPage      = Blogger.CreateLinksPost(content);
                var shortenedLinks = new List <string>();
                if (string.IsNullOrEmpty(linksPage))
                {
                    await
                    GenerateOutput(outputId, fileSize, fileFormat, imageCode, imageCodeBlog, linksPage, linksBackup, isUncensored, shortenedLinks);
                }
                else
                {
                    var firstShortenedLink = linksPage;
                    if (isUncensored)
                    {
                        firstShortenedLink = await ouoShortening.GetLink(linksPage);
                    }

                    foreach (var urlShortening in urlShortenings.Where(u => u.Enabled))
                    {
                        var shortenedLink = await urlShortening.GetLink(firstShortenedLink);

                        if (!string.IsNullOrEmpty(shortenedLink))
                        {
                            shortenedLinks.Add(shortenedLink);
                        }
                    }

                    await
                    GenerateOutput(outputId, fileSize, fileFormat, imageCode, imageCodeBlog, linksPage, linksBackup, isUncensored, shortenedLinks);
                }

                GenerateJavLibrary(shortenedLinks.Where(l => !l.Contains("shink")), fileSize, fileFormat, imageCode);
                GenerateWestern(shortenedLinks, fileSize, fileFormat, imageCode);
                GeneratePornBB(shortenedLinks, fileSize, fileFormat, imageCode);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.Message, ex);
            }
        }