Esempio n. 1
0
        public PVContract(VideoUrlParseResult parseResult, PVType type)
        {
            ParamIs.NotNull(() => parseResult);

            Author = parseResult.Author;
            Name = parseResult.Title;
            PVId = parseResult.Id;
            Service = parseResult.Service;
            ThumbUrl = parseResult.ThumbUrl;
            PVType = type;

            Url = PV.GetUrl(Service, PVId);
        }
Esempio n. 2
0
        public PVContract(VideoUrlParseResult parseResult, PVType type)
        {
            ParamIs.NotNull(() => parseResult);

            Author   = parseResult.Author;
            Name     = parseResult.Title;
            PVId     = parseResult.Id;
            Service  = parseResult.Service;
            ThumbUrl = parseResult.ThumbUrl;
            PVType   = type;

            Url = PV.GetUrl(Service, PVId);
        }
Esempio n. 3
0
        public PVContract GetPVByUrl(string pvUrl, PVType type = PVType.Original)
        {
            if (string.IsNullOrEmpty(pvUrl))
                throw new HttpResponseException(HttpStatusCode.BadRequest);

            var result = pvParser.ParseByUrl(pvUrl, true, permissionContext);

            if (!result.IsOk) {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = result.Exception.Message });
            }

            var contract = new PVContract(result, type);
            return contract;
        }
Esempio n. 4
0
        public PVContract(VideoUrlParseResult parseResult, PVType type)
        {
            ParamIs.NotNull(() => parseResult);

            Author      = parseResult.Author;
            Length      = parseResult.LengthSeconds ?? 0;
            Name        = parseResult.Title;
            PVId        = parseResult.Id;
            PublishDate = parseResult.UploadDate;
            Service     = parseResult.Service;
            ThumbUrl    = parseResult.ThumbUrl;
            PVType      = type;

            Url = PV.GetUrl(Service, PVId);
        }
Esempio n. 5
0
        public ActionResult CreatePVForSongByUrl(int songId, string pvUrl, PVType type)
        {
            var result = VideoServiceHelper.ParseByUrl(pvUrl, true);

            if (!result.IsOk)
            {
                return(Json(new GenericResponse <string>(false, result.Exception.Message)));
            }

            var contract = new PVContract(result, type);

            var view = RenderPartialViewToString("PVForSongEditRow", contract);

            return(Json(new GenericResponse <string>(view)));
        }
Esempio n. 6
0
        public async Task <ActionResult <PVContract> > GetPVByUrl(string pvUrl, PVType type = PVType.Original, bool getTitle = true)
        {
            if (string.IsNullOrEmpty(pvUrl))
            {
                return(BadRequest());
            }

            var result = await _pvParser.ParseByUrlAsync(pvUrl, getTitle, _permissionContext);

            if (!result.IsOk)
            {
                var msg = result.Exception.Message;
                return(BadRequest(msg));
            }

            var contract = new PVContract(result, type);

            return(contract);
        }
Esempio n. 7
0
        public PVContract GetPVByUrl(string pvUrl, PVType type = PVType.Original)
        {
            if (string.IsNullOrEmpty(pvUrl))
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var result = pvParser.ParseByUrl(pvUrl, true, permissionContext);

            if (!result.IsOk)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    ReasonPhrase = result.Exception.Message
                });
            }

            var contract = new PVContract(result, type);

            return(contract);
        }
Esempio n. 8
0
        public async Task <PVContract> GetPVByUrl(string pvUrl, PVType type = PVType.Original, bool getTitle = true)
        {
            if (string.IsNullOrEmpty(pvUrl))
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var result = await pvParser.ParseByUrlAsync(pvUrl, getTitle, permissionContext);

            if (!result.IsOk)
            {
                var msg = result.Exception.Message;
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    ReasonPhrase = msg,
                    Content      = new StringContent(msg)
                });
            }

            var contract = new PVContract(result, type);

            return(contract);
        }
Esempio n. 9
0
 private PVForSong CreatePV(PVService service = PVService.Youtube, PVType pvType = PVType.Original, DateTime?publishDate = null)
 {
     return(song.CreatePV(new PVContract {
         Service = service, PVId = "test", Name = "test", PublishDate = publishDate, PVType = pvType
     }));
 }
Esempio n. 10
0
 public virtual IEnumerable <T> OfType(PVType pvType)
 {
     return(PVs.Where(p => p.PVType == pvType));
 }
Esempio n. 11
0
        public ActionResult CreatePVForSongByUrl(int songId, string pvUrl, PVType type)
        {
            var result = VideoServiceHelper.ParseByUrl(pvUrl, true);

            if (!result.IsOk) {
                return Json(new GenericResponse<string>(false, result.Exception.Message));
            }

            var contract = new PVContract(result, type);

            var view = RenderPartialViewToString("PVForSongEditRow", contract);
            return Json(new GenericResponse<string>(view));
        }
Esempio n. 12
0
 public static PVContract PVContract(int id = 0, string pvId = "mikumikumiku", PVType pvType = PVType.Original, DateTime?publishDate = null)
 {
     return(new PVContract {
         Id = id, Service = PVService.Youtube, PVId = pvId, Name = "Nebula", PVType = pvType, PublishDate = publishDate
     });
 }