Exemple #1
0
        public ListEntry(XmlElement node)
        {
            string strValue = XmlUtility.GetText(node["enabled"], "true");

            if (strValue.Equals("true"))
            {
                m_Enabled = true;
            }
            else
            {
                m_Enabled = false;
            }

            m_DateTime = XmlUtility.GetDateTime(XmlUtility.GetText(node["datetime"], null), DateTime.Now);

            int linecount = XmlUtility.GetInt32(XmlUtility.GetText(node["linecount"], "0"), 0);

            m_Lines = new string[linecount];
            for (int i = 0; i < linecount; i++)
            {
                m_Lines[i] = XmlUtility.GetText(node["line" + i], "????");
            }

            int serial = XmlUtility.GetInt32(XmlUtility.GetText(node["mobile"], "0"), 0);

            if (serial != 0)
            {
                m_Mobile = (PlayerMobile)World.FindMobile(serial);
            }

            m_Type = (ListEntryType)XmlUtility.GetInt32(XmlUtility.GetText(node["type"], "0"), 0);
        }
Exemple #2
0
    internal static LatestInProfileUpdate?Parse(HtmlNode node, ListEntryType listEntryType)
    {
        var selector = listEntryType switch
        {
            ListEntryType.Anime => AnimeSelector,
            ListEntryType.Manga => MangaSelector,
            _ => throw new ArgumentOutOfRangeException(nameof(listEntryType), listEntryType, null)
        };
        var dataNode = node.SelectSingleNode(selector);

        if (dataNode == null)
        {
            return(null);
        }
        var hd = new HtmlDocument();

        hd.LoadHtml(dataNode.InnerHtml);
        dataNode = hd.DocumentNode;
        var link              = dataNode.SelectSingleNode("//a").Attributes["href"].Value;
        var id                = CommonParser.ExtractIdFromMalUrl(link);
        var dataText          = dataNode.SelectSingleNode("//div[1]/div[2]").InnerText.Trim();
        var splitted          = dataText.Split(Constants.DOT);
        var progressTypeValue = splitted[0].Trim();
        var scoreText         = splitted[1].Trim();
        var index             = progressTypeValue.IndexOfAny(Numbers);
        var progressValue     = 0;
        var progress          = GenericProgress.Unknown;

        if (index == -1)
        {
            progress = ProgressParser.Parse(progressTypeValue);
        }
        else
        {
            progress = ProgressParser.Parse(progressTypeValue.Substring(0, index - 1).Trim());
            var length = progressTypeValue.IndexOf('/') - index;
            if (length > 0)
            {
                progressValue = int.Parse(progressTypeValue.Substring(index, length));
            }
        }

        var score = 0;

        if (!scoreText.Contains('-'))
        {
            var scoreIndex = scoreText.LastIndexOf(' ');
            score = int.Parse(scoreText.Substring(scoreIndex));
        }

        return(new()
        {
            Id = id,
            Progress = progress,
            ProgressValue = progressValue,
            Score = score
        });
    }
}
Exemple #3
0
 public ListEntry(string[] lines, Mobile m, DateTime dt, ListEntryType type)
 {
     m_Lines    = lines;
     m_Mobile   = m;
     m_DateTime = dt;
     m_Enabled  = true;
     m_Type     = type;
 }
 public ListEntry(string[] lines, Mobile m, DateTime dt, ListEntryType type)
 {
     m_Lines    = lines;
     m_Mobile   = m;
     m_DateTime = dt;
     m_Enabled  = true;
     m_Type     = type;
     m_EntryID  = ((TimeSpan)(DateTime.Now - DateTime.MinValue)).TotalMilliseconds;
 }
Exemple #5
0
    internal static RecentUpdate ToRecentUpdate(this FeedItem feedItem, ListEntryType type)
    {
        var index                = feedItem.Description.IndexOf('-');
        var progressText         = feedItem.Description.Substring(0, index - 1).Trim();
        var progress             = ProgressParser.Parse(progressText);
        var di                   = feedItem.Description.LastIndexOf("-", StringComparison.OrdinalIgnoreCase);
        var oi                   = feedItem.Description.LastIndexOf(" of", StringComparison.OrdinalIgnoreCase);
        var progressedSubEntries = int.Parse(feedItem.Description.Substring(di + 2, oi - di - 2));

        return(new(type, CommonParser.ExtractIdFromMalUrl(feedItem.Link), feedItem.PublishingDateTimeOffset, progress, progressedSubEntries));
    }
Exemple #6
0
		public ListEntry(string[] lines, Mobile m, DateTime dt, ListEntryType type)
		{
			m_Lines = lines;
			m_Mobile = m;
			m_DateTime = dt;
			m_Enabled = true;
			m_Type = type;
		}
Exemple #7
0
		public ListEntry( XmlElement node )
		{
			string strValue = XmlUtility.GetText(node["enabled"], "true");
			if( strValue.Equals("true") )
				m_Enabled = true;
			else
				m_Enabled = false;

			m_DateTime = XmlUtility.GetDateTime( XmlUtility.GetText( node["datetime"], null ), DateTime.Now );

			int linecount = XmlUtility.GetInt32( XmlUtility.GetText( node["linecount"], "0" ), 0 );
			m_Lines = new string[linecount];
			for( int i=0; i<linecount; i++ )
			{
				m_Lines[i] = XmlUtility.GetText(node["line" + i], "????");
			}

			int serial = XmlUtility.GetInt32( XmlUtility.GetText( node["mobile"], "0" ), 0 );
			if( serial != 0 )
			{
				m_Mobile = (PlayerMobile)World.FindMobile( serial );
			}

			m_Type = (ListEntryType)XmlUtility.GetInt32( XmlUtility.GetText( node["type"], "0" ), 0 );
		}