Beispiel #1
0
        /// <summary>
        /// 网址解析器
        /// </summary>
        /// <param name="url"></param>
        /// <param name="mediaType"></param>
        /// <returns></returns>
        public ActionResult ParseMedia(MediaType mediaType, string url = null)
        {
            if (UserContext.CurrentUser == null)
                return Json(new { errorMessage = "您没有登录" }, JsonRequestBehavior.AllowGet);
            if (string.IsNullOrEmpty(url))
                return Json(new { errorMessage = "url不能为空" }, JsonRequestBehavior.AllowGet);

            if (!Utility.IsAllowableReferrer(Request))
                return Json(new { errorMessage = "站点不支持跨域访问" }, JsonRequestBehavior.AllowGet);
            List<string> keys = GetUrlParserKeys(mediaType);
            string key = keys.FirstOrDefault(n => url.ToLower().Contains(n.ToLower()));
            //若已经在短网址中存在,则直接返回结果
            ShortUrlService shortUrlService = new ShortUrlService();
            bool urlExists = false;
            string alias = shortUrlService.GetUrlAlias(url, out urlExists);
            //string alias = IdGenerator.Next().ToString();
            ParsedMediaService parsedMediaService = new ParsedMediaService();
            ParsedMedia entity = parsedMediaService.Get(alias);
            if (entity != null)
                return Json(entity, JsonRequestBehavior.AllowGet);

            if (string.IsNullOrEmpty(key))
                return View("~/Plugins/MediaParsers/" + mediaType.ToString() + "/Default.cshtml");

            return View("~/Plugins/MediaParsers/" + mediaType.ToString() + "/" + key + ".cshtml");
        }
Beispiel #2
0
        public ActionResult _VideoDetail(string alias)
        {
            if (string.IsNullOrEmpty(alias))
            {
                return new EmptyResult();
            }

            ParsedMedia pm = new ParsedMediaService().Get(alias);
            if (pm == null)
            {
                return new EmptyResult();
            }

            return View(pm);
        }