コード例 #1
0
ファイル: PVContract.cs プロジェクト: realzhaorong/vocadb
        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);
        }
コード例 #2
0
ファイル: PVContract.cs プロジェクト: sethura/vocadb
        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);
        }
コード例 #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;
        }
コード例 #4
0
ファイル: PVContract.cs プロジェクト: rijuntun/vocadb
        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);
        }
コード例 #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)));
        }
コード例 #6
0
ファイル: PVApiController.cs プロジェクト: AgFlore/vocadb
        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);
        }
コード例 #7
0
ファイル: PVApiController.cs プロジェクト: sethura/vocadb
        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);
        }
コード例 #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);
        }
コード例 #9
0
ファイル: SongTests.cs プロジェクト: rijuntun/vocadb
 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
     }));
 }
コード例 #10
0
ファイル: PVManager.cs プロジェクト: xcodeuuuuu66699/vocadb
 public virtual IEnumerable <T> OfType(PVType pvType)
 {
     return(PVs.Where(p => p.PVType == pvType));
 }
コード例 #11
0
ファイル: SongController.cs プロジェクト: realzhaorong/vocadb
        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));
        }
コード例 #12
0
ファイル: CreateEntry.cs プロジェクト: AgFlore/vocadb
 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
     });
 }