Esempio n. 1
0
 private ArtistInfo GetInfo(string cid, string referer = null)
 {
     try
     {
         var jfa = JsonConvert.DeserializeObject <JsonData_Fanbox_Artist>(GetWebCode($"https://api.fanbox.cc/creator.get?creatorId={cid}", referer));
         if (null != jfa.body)
         {
             var ai = new ArtistInfo()
             {
                 Id      = jfa.body.user.userId,
                 Cid     = cid,
                 AName   = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(jfa.body.user.name)),
                 PostUrl = referer ?? _referer
             };
             foreach (var link in jfa.body.profileLinks)
             {
                 if (link.Contains("twitter.com"))
                 {
                     ai.Twitter = $"{link}/status";
                     break;
                 }
             }
             return(ai);
         }
         return(null);
     }
     catch
     {
         throw;
     }
 }
Esempio n. 2
0
        public async override Task <ResultMessage> GetPostIDs(string uid)
        {
            return(await Task.Run(() =>
            {
                var bis = new List <BaseItem>();
                try
                {
                    string url = $"https://api.fanbox.cc/post.listCreator?creatorId={uid}&limit=10";
                    if (string.IsNullOrEmpty(_referer))
                    {
                        _referer = $"https://{uid}.fanbox.cc";
                    }

                    string nurl = GetUrls(GetWebCode(url), bis);
                    if (!string.IsNullOrEmpty(nurl))
                    {
                        GetPostIDs_Next(nurl, bis);
                    }
                    return ResultHelper.NoError(bis);
                }
                catch (Exception ex)
                {
                    GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
                    if (ex is WebException || ex is System.Net.Sockets.SocketException)
                    {
                        return ex.Message.Contains("401") ? ResultHelper.CookieError() : ResultHelper.WebError();
                    }
                    return ResultHelper.UnKnownError();
                }
            }));
        }
Esempio n. 3
0
 public async override Task <ResultMessage> GetPostIDs(string uid)
 {
     return(await Task.Run(() =>
     {
         try
         {
             _pidList = new HashSet <string>();
             var bis = GetPostIDsFromWebCode(uid);
             return ResultHelper.NoError(bis);
         }
         catch (Exception ex)
         {
             GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
             if (ex is WebException || ex is System.Net.Sockets.SocketException)
             {
                 return ex.Message.Contains("40") ? ResultHelper.CookieError() : ResultHelper.WebError();
             }
             else if (ex is InvalidDataException)
             {
                 return ResultHelper.UnKnownError("Post Error: " + ex.Message);
             }
             return ResultHelper.UnKnownError();
         }
     }));
 }
Esempio n. 4
0
 public async override Task<ResultMessage> GetArtistInfo(string url)
 {
     try
     {
         string ss = await GetWebCode("view-source:" + url);
         Match ma = _cidRegex.Match(ss);
         if (ma.Success)
         {
             string _cid = ma.Groups[1].Value;
             ss = ChangeUnicode(await GetAPI(string.Format(_artistUrl, _cid)));
             var jpa = JsonConvert.DeserializeObject<JsonData_Patreon_Artist>(ss);
             if (null != jpa.data)
             {
                 var ai = new ArtistInfo()
                 {
                     Id = _cid,
                     Cid = _cid,
                     AName = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(jpa.data.attributes.name)),
                     PostUrl = url,
                     PayLow = GlobalData.VM_MA.Artist.PayLow,
                     PayHigh = GlobalData.VM_MA.Artist.PayHigh
                 };
                 return ResultHelper.NoError(ai);
             }
             return ResultHelper.IOError();
         }
         return ResultHelper.PathError();
     }
     catch (Exception ex)
     {
         GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
         return ResultHelper.UnKnownError();
     }
 }
Esempio n. 5
0
        public MainWindow()
        {
            InitializeComponent();
            CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, CloseWindow));
            CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, MaximizeWindow, CanResizeWindow));
            CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, MinimizeWindow, CanMinimizeWindow));
            CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, RestoreWindow, CanResizeWindow));

            GlobalData.VM_MA = (ViewModels.VM_Main)DataContext;
            GlobalMethord.Init();
        }
Esempio n. 6
0
        private static void ChangeCulture(string cultureName)
        {
            ResourceDictionary dict = new ResourceDictionary();

            dict.Source = new Uri($"Styles/Style.{cultureName}.xaml", UriKind.Relative);
            if (Application.Current.Resources.MergedDictionaries.Count > 2)
            {
                Application.Current.Resources.MergedDictionaries.RemoveAt(2);
            }
            Application.Current.Resources.MergedDictionaries.Add(dict);
            Initialize();
            GlobalMethord.UpdateCulture();
        }
Esempio n. 7
0
 public async Task <ResultMessage> InitBrowser()
 {
     try
     {
         if (null != GlobalData.VM_MA.PatreonCefBrowser)
         {
             _cwb = (ChromiumWebBrowser)GlobalData.VM_MA.PatreonCefBrowser;
             if (!GlobalData.VM_MA.IsInitialized)
             {
                 while (!_cwb.IsBrowserInitialized)
                 {
                     await Task.Delay(500);
                 }
                 if (GlobalData.VM_MA.UseProxy)
                 {
                     if (!await CefHelper.SetProxy(_cwb, GlobalData.VM_MA.Proxy))
                     {
                         return(ResultHelper.WebError(GlobalLanguage.Msg_ErrorWebProxy));
                     }
                 }
                 return(await LoginCheck(await GetWebCode("view-source:https://www.patreon.com/home")));
             }
             if (_currentCookie != GlobalData.VM_MA.Cookies)
             {
                 return(await Logout());
             }
             return(ResultHelper.NoError(false));
         }
         CefHelper.Initialize();
         _cwb = new ChromiumWebBrowser();
         GlobalData.VM_MA.PatreonCefBrowser = _cwb;
         while (!_cwb.IsBrowserInitialized)
         {
             await Task.Delay(500);
         }
         if (GlobalData.VM_MA.UseProxy)
         {
             if (!await CefHelper.SetProxy(_cwb, GlobalData.VM_MA.Proxy))
             {
                 return(ResultHelper.WebError(GlobalLanguage.Msg_ErrorWebProxy));
             }
         }
         return(await LoginCheck(await GetWebCode("view-source:https://www.patreon.com/home")));
     }
     catch (Exception ex)
     {
         GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
         return(ResultHelper.UnKnownError());
     }
 }
Esempio n. 8
0
 private List <ArtistInfo> GetArtistListFromWebCode(string free, int index = 1)
 {
     try
     {
         List <ArtistInfo> ais    = new List <ArtistInfo>();
         string            sphtml = GetWebCode($"https://fantia.jp/mypage/users/plans?page={index}&type={free}free");
         Match             ma     = _artIdName.Match(sphtml);
         while (ma.Success)
         {
             var cid = ma.Groups[1].Value;
             var ana = ma.Groups[2].Value;
             int ind = ana.IndexOf('(');
             if (ind != -1)
             {
                 ana = ana.Substring(0, ind);
             }
             var ai = new ArtistInfo()
             {
                 Id      = cid,
                 Cid     = cid,
                 AName   = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(ana)),
                 PostUrl = $"https://fantia.jp/fanclubs/{cid}",
                 PayHigh = "0"
             };
             ais.Add(ai);
             ma = ma.NextMatch();
         }
         if (!string.IsNullOrEmpty(free))
         {
             ma = _artPlan.Match(sphtml);
             int i = 0;
             while (ma.Success)
             {
                 ais[i++].PayHigh = ma.Groups[1].Value.Replace(",", "");
                 ma = ma.NextMatch();
             }
         }
         if (sphtml.IndexOf(_nextP) != -1)
         {
             index++;
             ais.AddRange(GetArtistListFromWebCode(free, index));
         }
         return(ais);
     }
     catch
     {
         throw;
     }
 }
Esempio n. 9
0
 public async override Task <ResultMessage> GetArtistList()
 {
     try
     {
         string ss  = ChangeUnicode(await GetAPI(_pledgeUrl));
         var    jpp = JsonConvert.DeserializeObject <JsonData_Patreon_Pledge>(ss);
         if (null != jpp.data && null != jpp.included)
         {
             List <ArtistInfo> ais = new List <ArtistInfo>();
             var tais = GlobalData.VM_MA.ArtistList.ToList();
             if (tais.Count == 0)
             {
                 tais.Add(new ArtistInfo());
             }
             var incll = jpp.included.ToList();
             for (int i = 0; i < jpp.data.Length; i++)
             {
                 var inclu = incll.Find(x => x.id == jpp.data[i].relationships.campaign.data.id);
                 var ai    = new ArtistInfo()
                 {
                     Id      = inclu.id,
                     Cid     = inclu.id,
                     AName   = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(inclu.attributes.name)),
                     PostUrl = inclu.attributes.url,
                     PayHigh = jpp.data[i].attributes.amount_cents.ToString()
                 };
                 tais.Remove(ai);
                 ais.Add(ai);
             }
             ais.AddRange(tais);
             return(ResultHelper.NoError(ais));
         }
         if (ss == "{\"data\":[]}")
         {
             return(ResultHelper.NoError(new List <ArtistInfo>()));
         }
         return(ResultHelper.IOError());
     }
     catch (Exception ex)
     {
         GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
         return(ResultHelper.UnKnownError());
     }
 }
Esempio n. 10
0
        public async override Task <ResultMessage> GetArtistList()
        {
            return(await Task.Run(() =>
            {
                try
                {
                    var ais = new List <ArtistInfo>();
                    var tais = GlobalData.VM_MA.ArtistList.ToList();
                    if (tais.Count == 0)
                    {
                        tais.Add(new ArtistInfo());
                    }

                    var jfp = JsonConvert.DeserializeObject <JsonData_Fanbox_Plan>(GetWebCode("https://api.fanbox.cc/plan.listSupporting", "https://www.fanbox.cc/creators/supporting"));
                    if (null != jfp.body)
                    {
                        foreach (var pl in jfp.body)
                        {
                            var ai = GetInfo(pl.creatorId, $"https://www.fanbox.cc/@{pl.creatorId}");
                            if (null != ai)
                            {
                                ai.PayHigh = pl.fee.ToString();
                                tais.Remove(ai);
                                ais.Add(ai);
                            }
                        }
                        ais.AddRange(tais);
                        return ResultHelper.NoError(ais);
                    }
                    return ResultHelper.IOError();
                }
                catch (Exception ex)
                {
                    GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
                    if (ex is WebException || ex is System.Net.Sockets.SocketException)
                    {
                        return ex.Message.Contains("40") ? ResultHelper.CookieError() : ResultHelper.WebError();
                    }
                    return ResultHelper.UnKnownError();
                }
            }));
        }
Esempio n. 11
0
        public async override Task <ResultMessage> GetArtistInfo(string url)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    Match ma = _artUrl.Match(url);
                    if (!ma.Success)
                    {
                        return ResultHelper.PathError();
                    }
                    string cid = ma.Groups[1].Value;

                    var jfa = JsonConvert.DeserializeObject <JsonData_Fantia_Artist>(GetWebCode($"https://fantia.jp/api/v1/fanclubs/{cid}"));
                    if (null != jfa.fanclub)
                    {
                        var ai = new ArtistInfo()
                        {
                            Id = cid,
                            AName = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(jfa.fanclub.creator_name)),
                            Cid = cid,
                            PostUrl = $"https://fantia.jp/fanclubs/{cid}",
                            PayLow = GlobalData.VM_MA.Artist.PayLow,
                            PayHigh = GlobalData.VM_MA.Artist.PayHigh
                        };
                        return ResultHelper.NoError(ai);
                    }
                    return ResultHelper.IOError();
                }
                catch (Exception ex)
                {
                    GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
                    if (ex is WebException || ex is System.Net.Sockets.SocketException)
                    {
                        return ex.Message.Contains("40") ? ResultHelper.CookieError() : ResultHelper.WebError();
                    }
                    return ResultHelper.UnKnownError();
                }
            }));
        }
Esempio n. 12
0
        public async override Task <ResultMessage> GetArtistInfo(string url)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    Match ma = _artUrl.Match(url);
                    if (!ma.Success)
                    {
                        ma = _artUrl2.Match(url);
                        if (!ma.Success)
                        {
                            return ResultHelper.PathError();
                        }
                    }
                    _referer = $"https://www.fanbox.cc/@{ma.Groups[1].Value}";

                    var ai = GetInfo(ma.Groups[1].Value);
                    if (null != ai)
                    {
                        ai.PayLow = GlobalData.VM_MA.Artist.PayLow;
                        ai.PayHigh = GlobalData.VM_MA.Artist.PayHigh;
                        return ResultHelper.NoError(ai);
                    }
                    return ResultHelper.IOError();
                }
                catch (Exception ex)
                {
                    GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
                    if (ex is WebException || ex is System.Net.Sockets.SocketException)
                    {
                        return ex.Message.Contains("40") ? ResultHelper.CookieError() : ResultHelper.WebError();
                    }
                    return ResultHelper.UnKnownError();
                }
            }));
        }
Esempio n. 13
0
        public async override Task <ResultMessage> GetArtistList()
        {
            return(await Task.Run(() =>
            {
                try
                {
                    List <ArtistInfo> ais = new List <ArtistInfo>();
                    //有料
                    ais.AddRange(GetArtistListFromWebCode("not_"));
                    //無料
                    ais.AddRange(GetArtistListFromWebCode(string.Empty));

                    var tais = GlobalData.VM_MA.ArtistList.ToList();
                    if (tais.Count == 0)
                    {
                        tais.Add(new ArtistInfo());
                    }
                    tais.ForEach(x =>
                    {
                        if (!ais.Contains(x))
                        {
                            ais.Add(x);
                        }
                    });
                    return ResultHelper.NoError(ais);
                }
                catch (Exception ex)
                {
                    GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
                    if (ex is WebException || ex is System.Net.Sockets.SocketException)
                    {
                        return ex.Message.Contains("40") ? ResultHelper.CookieError() : ResultHelper.WebError();
                    }
                    return ResultHelper.UnKnownError();
                }
            }));
        }
Esempio n. 14
0
        public FantiaItem GetUrls(string pid)
        {
            try
            {
                var jfp = JsonConvert.DeserializeObject <JsonData_Fantia_Post>(GetWebCode($"https://fantia.jp/api/v1/posts/{pid}"));
                if (null != jfp.post)
                {
                    FantiaItem fi = new FantiaItem();
                    if (DateTime.TryParse(jfp.post.posted_at, out DateTime dt))
                    {
                        fi.CreateDate = dt;
                    }
                    if (DateTime.TryParse(jfp.post.converted_at, out dt))
                    {
                        fi.UpdateDate = dt;
                    }

                    fi.FID   = jfp.post.id.ToString();
                    fi.Title = GlobalMethord.RemoveAllDot(GlobalMethord.ReplacePath(jfp.post.title));
                    GlobalData.VM_MA.PostTitle = fi.Title;
                    if (!string.IsNullOrEmpty(jfp.post.comment))
                    {
                        fi.Comments.Add(jfp.post.comment);
                        fi.Comments.Add(string.Empty);
                    }
                    if (null != jfp.post.thumb)
                    {
                        fi.CoverPic      = jfp.post.thumb.original;
                        fi.CoverPicThumb = jfp.post.thumb.ogp;
                    }
                    if (DateTime.TryParse(jfp.post.deadline, out dt))
                    {
                        fi.DeadDate = dt.ToString("yyyy/MM/dd HH:mm:ss");
                    }
                    else
                    {
                        fi.DeadDate = "---";
                    }

                    foreach (var ct in jfp.post.post_contents)
                    {
                        var fee = 0;
                        if (null != ct.plan)
                        {
                            fee = ct.plan.price;
                        }
                        var stitle = $"${fee}_{GlobalMethord.RemoveAllDot(GlobalMethord.ReplacePath(ct.title))}";
                        fi.Comments.Add("------------------------------------------------------------------------------------------");
                        fi.Comments.Add(stitle);
                        fi.Comments.Add(string.Empty);
                        if (ct.visible_status == "visible")
                        {
                            if (ct.category != "blog" && !string.IsNullOrEmpty(ct.comment))
                            {
                                fi.Comments.Add(ct.comment);
                                fi.Comments.Add(string.Empty);
                            }
                            if (ct.category == "photo_gallery")
                            {
                                var imgs = ct.post_content_photos;
                                foreach (var img in imgs)
                                {
                                    var imgUrl = img.url.original;
                                    if (!string.IsNullOrEmpty(img.comment))
                                    {
                                        fi.Comments.Add(img.comment);
                                    }
                                    var ffn = imgUrl.Substring(0, imgUrl.IndexOf("?Key"));
                                    var ext = ffn.Substring(ffn.LastIndexOf('.'));
                                    var fn  = $"{img.id}{ext}";
                                    fi.Comments.Add($"<{GlobalLanguage.Text_ImagePref} {fn}>");
                                    fi.FileNames.Add(fn);
                                    fi.ContentUrls.Add(imgUrl);
                                    fi.Fees.Add($"{fee}");
                                    fi.PTitles.Add(stitle);
                                }
                            }
                            else if (ct.category == "file")
                            {
                                fi.Comments.Add($"<{GlobalLanguage.Text_FilePref} {ct.filename}>");
                                fi.FileNames.Add(ct.filename);
                                fi.ContentUrls.Add($"https://fantia.jp{ct.download_uri}");
                                fi.Fees.Add($"{fee}");
                                fi.PTitles.Add(stitle);
                            }
                            else if (ct.category == "blog")
                            {
                                try
                                {
                                    JObject dd = JsonConvert.DeserializeObject(ct.comment) as JObject;
                                    JArray  ja = JArray.Parse(dd["ops"].ToString());

                                    foreach (var js in ja)
                                    {
                                        var     ss   = js.SelectToken("insert");
                                        dynamic stem = ss;
                                        if (ss.Type == JTokenType.String)
                                        {
                                            fi.Comments.Add(stem.Value.Replace("\\n", Environment.NewLine));
                                        }
                                        else if (ss.Type == JTokenType.Object)
                                        {
                                            string imgUrl = stem.fantiaImage.url;
                                            var    ffn    = imgUrl.Substring(0, imgUrl.IndexOf("?Key"));
                                            var    ext    = ffn.Substring(ffn.LastIndexOf('.'));
                                            var    fn     = $"{stem.fantiaImage.id}{ext}";
                                            fi.Comments.Add($"<{GlobalLanguage.Text_ImagePref} {fn}>");
                                            fi.FileNames.Add(fn);
                                            fi.ContentUrls.Add($"https://fantia.jp{stem.fantiaImage.original_url}");
                                            fi.Fees.Add($"{fee}");
                                            fi.PTitles.Add(stitle);
                                        }
                                        else
                                        {
                                            throw new Exception("Blog type unknown: " + ss.Type.ToString());
                                        }
                                    }
                                }
                                catch
                                {
                                    throw;
                                }
                            }
                        }
                    }
                    return(fi);
                }
                return(null);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 15
0
        private string GetUrls(string jsondata, IList <BaseItem> bis)
        {
            var fd = JsonConvert.DeserializeObject <JsonData_Fanbox_Post>(jsondata);

            if (null != fd.body && null != fd.body.items)
            {
                foreach (var po in fd.body.items)
                {
                    var pi = new FanboxItem()
                    {
                        PID           = po.id,
                        Fee           = po.feeRequired.ToString(),
                        Title         = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(po.title)),
                        CoverPic      = po.coverImageUrl,
                        CoverPicThumb = po.coverImageUrl,
                        IsLiked       = po.isLiked
                    };
                    GlobalData.VM_MA.PostTitle = pi.Title;
                    if (DateTime.TryParse(po.publishedDatetime, out DateTime dt))
                    {
                        pi.CreateDate = dt;
                    }
                    if (DateTime.TryParse(po.updatedDatetime, out dt))
                    {
                        pi.UpdateDate = dt;
                    }
                    if (GlobalMethord.OverPayment(int.Parse(pi.Fee)) || GlobalMethord.OverTime(pi.UpdateDate))
                    {
                        pi.Skip = true;
                    }

                    if (null != po.body)
                    {
                        switch (po.type)
                        {
                        case "file":
                        {
                            if (!string.IsNullOrEmpty(po.body.text))
                            {
                                pi.Comments.Add(po.body.text);
                                pi.Comments.Add(string.Empty);
                            }
                            foreach (var finfo in po.body.files)
                            {
                                pi.ContentUrls.Add(finfo.url);
                                var fn = $"{finfo.name}.{finfo.extension}";
                                pi.FileNames.Add(fn);
                                pi.Comments.Add($"<{GlobalLanguage.Text_FilePref} {fn} ({GetSize(finfo.size)})>");
                            }
                        }
                        break;

                        case "image":
                        {
                            if (!string.IsNullOrEmpty(po.body.text))
                            {
                                pi.Comments.Add(po.body.text);
                                pi.Comments.Add(string.Empty);
                            }
                            int index = 1;
                            foreach (var iinfo in po.body.images)
                            {
                                pi.MediaUrls.Add(iinfo.originalUrl);
                                var fn = $"{index++}.{iinfo.extension}";
                                pi.MediaNames.Add(fn);
                                pi.Comments.Add($"<{GlobalLanguage.Text_ImagePref} {fn} ({iinfo.width}x{iinfo.height}px)>");
                            }
                        }
                        break;

                        case "article":
                        {
                            int index_pic = 1;
                            foreach (var binfo in po.body.blocks)
                            {
                                switch (binfo.type)
                                {
                                case "p":
                                    pi.Comments.Add(binfo.text);
                                    break;

                                case "file":
                                    if (null != po.body.fileMap && po.body.fileMap.TryGetValue(binfo.fileId, out FileItem fitem))
                                    {
                                        pi.ContentUrls.Add(fitem.url);
                                        var fn = $"{fitem.name}.{fitem.extension}";
                                        pi.FileNames.Add(fn);
                                        pi.Comments.Add($"<{GlobalLanguage.Text_FilePref} {fn} ({GetSize(fitem.size)})>");
                                    }
                                    break;

                                case "image":
                                    if (null != po.body.imageMap && po.body.imageMap.TryGetValue(binfo.imageId, out ImageItem iitem))
                                    {
                                        pi.MediaUrls.Add(iitem.originalUrl);
                                        var fn = $"{index_pic++}.{iitem.extension}";
                                        pi.MediaNames.Add(fn);
                                        pi.Comments.Add($"<{GlobalLanguage.Text_ImagePref} {fn} ({iitem.width}x{iitem.height}px)>");
                                    }
                                    break;

                                case "embed":
                                    if (null != po.body.embedMap && po.body.embedMap.TryGetValue(binfo.embedId, out EmbedItem eitem))
                                    {
                                        pi.Comments.Add(string.Empty);
                                        if (eitem.serviceProvider == "twitter" && !string.IsNullOrEmpty(GlobalData.VM_MA.Artist.Twitter))
                                        {
                                            pi.Comments.Add($"<{GlobalLanguage.Text_LinkPref} {GlobalData.VM_MA.Artist.Twitter}/{eitem.contentId} >");
                                        }
                                        else if (eitem.serviceProvider == "fanbox")
                                        {
                                            pi.Comments.Add($"<{GlobalLanguage.Text_LinkPref} {GlobalData.VM_MA.Artist.PostUrl}/posts/{eitem.contentId.Split('/').Last()} >");
                                        }
                                        else
                                        {
                                            pi.Comments.Add($"<{GlobalLanguage.Text_LinkPref} {eitem.serviceProvider} ({eitem.contentId})>");
                                        }
                                        pi.Comments.Add(string.Empty);
                                    }
                                    break;
                                }
                            }
                        }
                        break;

                        case "text":
                        {
                            if (!string.IsNullOrEmpty(po.body.text))
                            {
                                pi.Comments.Add(po.body.text);
                            }
                        }
                        break;
                        }
                    }
                    bis.Add(pi);
                    GlobalData.VM_MA.PostCount++;
                }
                return(fd.body.nextUrl ?? null);
            }
            return(null);
        }
Esempio n. 16
0
        public async override Task<ResultMessage> GetPostIDs(string uid)
        {
            try
            {
                string ss = ChangeUnicode(await GetAPI(string.Format(_postUrl, uid)));
                List<BaseItem> pis = new List<BaseItem>();
                while (true)
                {
                    var jpp = JsonConvert.DeserializeObject<JsonData_Patreon_Post>(ss);
                    if (null != jpp.data && null != jpp.included && null != jpp.meta)
                    {
                        var incll = jpp.included.ToList();
                        for (int i = 0; i < jpp.data.Length; i++)
                        {
                            if (DateTime.TryParse(jpp.data[i].attributes.published_at, out DateTime dt))
                            {
                                if (GlobalMethord.OverTime(dt))
                                {
                                    return ResultHelper.NoError(pis);
                                }
                            }

                            PatreonItem pi = new PatreonItem()
                            {
                                CreateDate = dt,
                                UpdateDate = dt,
                                PID = jpp.data[i].id,
                                Title = GlobalMethord.RemoveLastDot(GlobalMethord.ReplacePath(jpp.data[i].attributes.title)),
                                IsLiked = jpp.data[i].attributes.current_user_has_liked,
                                PLink = jpp.data[i].attributes.url
                            };
                            GlobalData.VM_MA.PostTitle = pi.Title;
                            if (!string.IsNullOrEmpty(jpp.data[i].attributes.content))
                            {
                                pi.Comments.Add(await GetWebContent(_htmlImg.Replace(jpp.data[i].attributes.content, "")));
                            }
                            else if (!string.IsNullOrEmpty(jpp.data[i].attributes.content_teaser_text))
                            {
                                pi.Comments.Add(jpp.data[i].attributes.content_teaser_text);
                            }
                            if (jpp.data[i].attributes.current_user_can_view)
                            {
                                if (null != jpp.data[i].attributes.image)
                                {
                                    pi.CoverPicThumb = jpp.data[i].attributes.image.thumb_url;
                                }
                                if (null != jpp.data[i].attributes.embed)
                                {
                                    pi.Comments.Add($"<{GlobalLanguage.Text_LinkPref} {jpp.data[i].attributes.embed.url} >");
                                }

                                if (null != jpp.data[i].relationships.media)
                                {
                                    for (int j = 0; j < jpp.data[i].relationships.media.data.Length; j++)
                                    {
                                        var inclu = incll.Find(x => x.id == jpp.data[i].relationships.media.data[j].id);
                                        if (string.IsNullOrEmpty(inclu.attributes.file_name))
                                        {
                                            inclu.attributes.file_name = "default.";
                                            if (!string.IsNullOrEmpty(inclu.attributes.mimetype))
                                            {
                                                var tep = inclu.attributes.mimetype.Split('/');
                                                if (tep.Length == 2)
                                                {
                                                    inclu.attributes.file_name += tep[1];
                                                }
                                                else
                                                {
                                                    inclu.attributes.file_name += inclu.attributes.mimetype;
                                                }
                                            }
                                            else
                                                inclu.attributes.file_name += "png";
                                        }
                                        else if (inclu.attributes.file_name.StartsWith("https://"))
                                        {
                                            continue;
                                        }
                                        pi.ContentUrls.Add(inclu.attributes.image_urls.original);
                                        pi.FileNames.Add(inclu.attributes.file_name);
                                        pi.Comments.Add($"<{GlobalLanguage.Text_FilePref} {inclu.attributes.file_name}>");
                                    }
                                }
                            }
                            pis.Add(pi);
                            GlobalData.VM_MA.PostCount++;
                        }
                        if (null != jpp.meta.pagination.cursors)
                        {
                            ss = ChangeUnicode(await GetAPI(string.Format(_nextUrl, uid, jpp.meta.pagination.cursors.next)));
                            continue;
                        }
                        return ResultHelper.NoError(pis);
                    }
                    return ResultHelper.IOError();
                }
            }
            catch (Exception ex)
            {
                GlobalMethord.ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + "-----------------------------------------------");
                return ResultHelper.UnKnownError();
            }
        }
Esempio n. 17
0
        private void GetUrls_Loop(int pid, List <BaseItem> bis)
        {
            try
            {
                var jfp = JsonConvert.DeserializeObject <JsonData_Fantia_Post>(GetWebCode($"https://fantia.jp/api/v1/posts/{pid}"));
                if (null != jfp.post)
                {
                    FantiaItem fi = new FantiaItem()
                    {
                        FID   = jfp.post.id.ToString(),
                        Title = GlobalMethord.RemoveAllDot(GlobalMethord.ReplacePath(jfp.post.title)),
                    };
                    GlobalData.VM_MA.PostTitle = fi.Title;
                    if (DateTime.TryParse(jfp.post.posted_at, out DateTime dt))
                    {
                        fi.CreateDate = dt;
                    }
                    if (DateTime.TryParse(jfp.post.converted_at, out dt))
                    {
                        fi.UpdateDate = dt;
                    }

                    if (!string.IsNullOrEmpty(jfp.post.comment))
                    {
                        fi.Comments.Add(jfp.post.comment);
                        fi.Comments.Add(string.Empty);
                    }
                    if (null != jfp.post.thumb)
                    {
                        fi.CoverPic      = jfp.post.thumb.original;
                        fi.CoverPicThumb = jfp.post.thumb.ogp;
                    }
                    if (DateTime.TryParse(jfp.post.deadline, out dt))
                    {
                        fi.DeadDate = dt.ToString("yyyy/MM/dd HH:mm:ss");
                    }
                    else
                    {
                        fi.DeadDate = "---";
                    }

                    var contents = jfp.post.post_contents;
                    foreach (var ct in contents)
                    {
                        var fee = 0;
                        if (null != ct.plan)
                        {
                            fee = ct.plan.price;
                        }
                        var stitle = $"${fee}_{GlobalMethord.RemoveAllDot(GlobalMethord.ReplacePath(ct.title))}";
                        fi.Comments.Add("------------------------------------------------------------------------------------------");
                        fi.Comments.Add(stitle);
                        fi.Comments.Add(string.Empty);
                        if (ct.visible_status == "visible")
                        {
                            if (!string.IsNullOrEmpty(ct.comment))
                            {
                                fi.Comments.Add(ct.comment);
                                fi.Comments.Add(string.Empty);
                            }
                            if (ct.category == "photo_gallery")
                            {
                                var imgs = ct.post_content_photos;
                                foreach (var img in imgs)
                                {
                                    var imgUrl = img.url.original;

                                    if (!string.IsNullOrEmpty(img.comment))
                                    {
                                        fi.Comments.Add(img.comment);
                                    }
                                    var ffn = imgUrl.Substring(0, imgUrl.IndexOf("?Key"));
                                    var ext = ffn.Substring(ffn.LastIndexOf('.'));
                                    var fn  = $"{img.id}{ext}";
                                    fi.Comments.Add($"<{GlobalLanguage.Text_ImagePref} {fn}>");
                                    fi.FileNames.Add(fn);
                                    fi.ContentUrls.Add(imgUrl);
                                    fi.Fees.Add($"{fee}");
                                    fi.PTitles.Add(stitle);
                                }
                            }
                            else if (ct.category == "file")
                            {
                                fi.Comments.Add($"<{GlobalLanguage.Text_FilePref} {ct.filename}>");
                                fi.FileNames.Add(ct.filename);
                                fi.ContentUrls.Add($"https://fantia.jp{ct.download_uri}");
                                fi.Fees.Add($"{fee}");
                                fi.PTitles.Add(stitle);
                            }
                        }
                    }
                    bis.Add(fi);
                    GlobalData.VM_MA.PostCount++;
                    if (null != jfp.post.links && null != jfp.post.links.previous)
                    {
                        if (!DateTime.TryParse(jfp.post.links.previous.converted_at, out DateTime dtp))
                        {
                            if (!DateTime.TryParse(jfp.post.links.previous.posted_at, out dtp))
                            {
                                GetUrls_Loop(jfp.post.links.previous.id, bis);
                                return;
                            }
                        }
                        if (!GlobalMethord.OverTime(dtp))
                        {
                            GetUrls_Loop(jfp.post.links.previous.id, bis);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }