Example #1
0
        public static async Task <Pixeez.Objects.UgoiraInfo> GetUgoiraMetaInfo(this PixivItem item)
        {
            Pixeez.Objects.UgoiraInfo result = null;
            long id = 0;

            if (item.IsWork() && long.TryParse(item.ID, out id))
            {
                if (item.Ugoira is Pixeez.Objects.UgoiraInfo)
                {
                    result = item.Ugoira;
                }
                else if (item.Illust.UgoiraMeta is Pixeez.Objects.UgoiraInfo)
                {
                    result      = item.Illust.UgoiraMeta;
                    item.Ugoira = result;
                }
                else
                {
                    result = await GetUgoiraMetaInfo(id);

                    item.Illust.UgoiraMeta = result;
                    item.Ugoira            = result;
                }
            }
            return(result);
        }
Example #2
0
        public static async Task <Pixeez.Objects.UgoiraInfo> GetUgoiraMetaInfo(this long id)
        {
            Pixeez.Objects.UgoiraInfo result = null;
            if (id > 0)
            {
                try
                {
                    var url       = $"https://www.pixiv.net/ajax/illust/{id}/ugoira_meta";
                    var json_text = await Application.Current.GetRemoteJsonAsync(url);

                    if (!string.IsNullOrEmpty(json_text))
                    {
                        var data = JsonConvert.DeserializeObject <Pixeez.Objects.UgoiraAjaxMetadata>(json_text);
                        if (data is Pixeez.Objects.UgoiraAjaxMetadata)
                        {
                            result = data.Meta;
                        }
                    }
                    else
                    {
                        result = await GetUgoiraMetaInfo(id, tokens : null);
                    }
                }
                catch (Exception ex) { ex.ERROR($"GetUgoiraMetaInfo_{id}"); }
            }
            return(result);
        }
Example #3
0
        public static async Task <Pixeez.Objects.UgoiraInfo> GetUgoiraMetaInfo(this Pixeez.Objects.Work work)
        {
            Pixeez.Objects.UgoiraInfo result = null;
            if (work is Pixeez.Objects.Work)
            {
                if (work.UgoiraMeta is Pixeez.Objects.UgoiraInfo)
                {
                    result = work.UgoiraMeta;
                }
                else
                {
                    result = await GetUgoiraMetaInfo(work.Id ?? 0);

                    work.UgoiraMeta = result;
                }
            }
            return(result);
        }
Example #4
0
        public static async Task <Pixeez.Objects.UgoiraInfo> GetUgoiraMeta(this Pixeez.Objects.Work Illust, bool ajax = false)
        {
            Pixeez.Objects.UgoiraInfo info = null;
            long id = 0;

            try
            {
                if (Illust.IsUgoira)
                {
                    id = Illust.Id.Value;
                    if (Illust.UgoiraMeta is Pixeez.Objects.UgoiraInfo)
                    {
                        info = Illust.UgoiraMeta;
                    }
                    else
                    {
                        if (ajax)
                        {
                            info = await GetUgoiraMetaInfo(id);
                        }
                        else
                        {
                            var tokens = await CommonHelper.ShowLogin();

                            var ugoira_meta = await tokens.GetUgoiraMetadata(id);

                            info = ugoira_meta is Pixeez.Objects.UgoiraMetadata ? ugoira_meta.Metadata : null;
                        }
                        if (info is Pixeez.Objects.UgoiraInfo)
                        {
                            Illust.UgoiraMeta = info;
                        }
                    }
                }
            }
            catch (Exception ex) { ex.ERROR($"GetUgoiraMeta_{id}"); }
            return(info);
        }
Example #5
0
        public static async Task <Pixeez.Objects.UgoiraInfo> GetUgoiraMetaInfo(this long id, Pixeez.Tokens tokens = null)
        {
            Pixeez.Objects.UgoiraInfo result = null;
            try
            {
                if (tokens == null)
                {
                    tokens = await CommonHelper.ShowLogin();
                }
                var meta = await tokens.GetUgoiraMetadata(id);

                result = meta.Metadata;
                if (string.IsNullOrEmpty(result.Src) && !string.IsNullOrEmpty(result.Urls.Medium))
                {
                    result.Src = result.Urls.Medium;
                }
                if (string.IsNullOrEmpty(result.OriginalSrc) && !string.IsNullOrEmpty(result.Src))
                {
                    result.OriginalSrc = result.Src.Replace("600x600", "1920x1080");
                }
            }
            catch (Exception ex) { ex.ERROR($"GetUgoiraMetaInfo_{id}"); }
            return(result);
        }