Показать сообщение отдельно
  #1  
Старый 15.03.2008, 05:48
diablist diablist вне форума
Прохожий
 
Регистрация: 15.03.2008
Сообщения: 11
Репутация: 10
Восклицание Помогите с переводом C# на Delphi

Помогите пожайлуста перевести эту функцию на Делфи:
Код:
    public class YouTubeDownloader: BaseVideoDownloader
    {
        public const string SiteName = "You Tube";

        //http://www.youtube.com/watch?v=5zOevLN3Tic
        public const string UrlPattern = @"(?:[Yy][Oo][Uu][Tt][Uu][Bb][Ee]\.[Cc][Oo][Mm]/watch\?v=)(\w[\w|-]*)";

        protected override ResourceLocation ResolveVideoURL(string url, string pageData, 
            out string videoTitle)
        {
            videoTitle = TextUtil.JustAfter(pageData, "<meta name=\"title\" content=\"", "\">"); 

            return ResourceLocation.FromURL(String.Format("{0}/get_video?video_id={1}&t={2}", TextUtil.GetDomain(url),
                TextUtil.JustAfter(url, "v=", "&"), TextUtil.JustAfter(pageData, "&t=", "&hl=")));
        }
    }
}

и еще этих парочку, если не тяжело

Код:
internal static class TextUtil
    {
        internal static string JustBefore(string Str, string Seq)
        {
            string Orgi = Str;
            try
            {
                Str = Str.ToLower();
                Seq = Seq.ToLower();

                return Orgi.Substring(0, Str.Length - (Str.Length - Str.IndexOf(Seq)));
            }
            catch (Exception)
            {
                return "";
            }
        }

        internal static string GetDomain(String URL)
        {
            return URL.Substring(0, URL.LastIndexOf("/"));
        }

        internal static string GetFilename(String URL)
        {
            string Filename = URL.Substring(URL.LastIndexOf("/") + 2, URL.Length - URL.LastIndexOf("/") - 2);

            if (Filename.IndexOf("&") != -1)
                Filename = JustBefore(Filename, "&");

            return Filename;
        }

        internal static string JustAfter(string Str, string Seq, string SeqEnd)
        {
            string Orgi = Str;
            try
            {
                Str = Str.ToLower();
                Seq = Seq.ToLower();

                int i = Str.IndexOf(Seq);

                if (i < 0)
                    return null;

                i = i + Seq.Length;

                int j = Str.IndexOf(SeqEnd, i);
                int end;

                if (j > 0) end = j - i;
                else end = Str.Length - i;

                return Orgi.Substring(i, end);
            }
            catch (Exception)
            {
                return "";
            }
        }

        internal static string JustAfter(string Str, string Seq)
        {
            string Orgi = Str;
            try
            {
                Str = Str.ToLower();
                Seq = Seq.ToLower();

                int i = Str.IndexOf(Seq);

                if (i < 0)
                    return null;

                i = i + Seq.Length;

                return Orgi.Substring(i, Str.Length - i);
            }
            catch (Exception)
            {
                return "";
            }
        }
    }
Ответить с цитированием