예제 #1
0
        public ActionResult ByPVBase(PVService service, string pvId, string callback,
                                     DataFormat format = DataFormat.Auto)
        {
            var song = Service.GetSongWithPV(s => new EntryBaseContract(s), service, pvId);

            return(Object(song, format, callback));
        }
예제 #2
0
        public static string VideoServiceLinkUrl(this HtmlHelper htmlHelper, PVService service)
        {
            switch (service)
            {
            case PVService.Bilibili:
                return(UrlHelper.GenerateContentUrl("~/Content/ExtIcons/bilibili.png", new HttpContextWrapper(HttpContext.Current)));

            case PVService.File:
                return(UrlHelper.GenerateContentUrl("~/Content/Icons/music.png", new HttpContextWrapper(HttpContext.Current)));

            case PVService.NicoNicoDouga:
                return(UrlHelper.GenerateContentUrl("~/Content/nico.png", new HttpContextWrapper(HttpContext.Current)));

            case PVService.Piapro:
                return(UrlHelper.GenerateContentUrl("~/Content/ExtIcons/piapro.png", new HttpContextWrapper(HttpContext.Current)));

            case PVService.SoundCloud:
                return(UrlHelper.GenerateContentUrl("~/Content/Icons/soundcloud.png", new HttpContextWrapper(HttpContext.Current)));

            case PVService.Youtube:
                return(UrlHelper.GenerateContentUrl("~/Content/youtube.png", new HttpContextWrapper(HttpContext.Current)));

            case PVService.Vimeo:
                return(UrlHelper.GenerateContentUrl("~/Content/ExtIcons/vimeo.png", new HttpContextWrapper(HttpContext.Current)));

            default:
                return(string.Empty);
            }
        }
예제 #3
0
        public ActionResult ByPV(PVService service, string pvId, ContentLanguagePreference?lang, string callback,
                                 DataFormat format = DataFormat.Auto)
        {
            var song = Service.GetSongWithPV(s => new SongForApiContract(s, lang ?? ContentLanguagePreference.Default), service, pvId);

            return(Object(song, format, callback));
        }
예제 #4
0
        public ActionResult ByPVBase(PVService service, string pvId, string callback,
            DataFormat format = DataFormat.Auto)
        {
            var song = Service.GetSongWithPV(s => new EntryBaseContract(s), service, pvId);

            return Object(song, format, callback);
        }
예제 #5
0
        public ActionResult ByPV(PVService service, string pvId, ContentLanguagePreference? lang, string callback, 
            DataFormat format = DataFormat.Auto)
        {
            var song = Service.GetSongWithPV(s => new SongForApiContract(s, lang ?? ContentLanguagePreference.Default), service, pvId);

            return Object(song, format, callback);
        }
예제 #6
0
        public static T GetPV <T>(T[] allPvs, PVService service)
            where T : class, IPV
        {
            var servicePvs = allPvs.Where(p => p.Service == service).ToArray();

            return(servicePvs.FirstOrDefault(p => p.PVType == PVType.Original)
                   ?? servicePvs.FirstOrDefault(p => p.PVType == PVType.Reprint)
                   ?? servicePvs.FirstOrDefault());
        }
예제 #7
0
        public static T GetPV <T>(T[] allPvs, PVService service)
            where T : class, IPV
        {
            var servicePvs = allPvs.Where(p => p.Service == service).ToArray();

            return(GetPV(servicePvs, true,
                         p => p.PVType == PVType.Original,
                         p => p.PVType == PVType.Reprint));
        }
예제 #8
0
        public PVContract PVForSongAndService(int songId, PVService service)
        {
            return(HandleQuery(ctx => {
                var pvs = ctx.OfType <PVForSong>().Query().Where(pv => pv.Song.Id == songId && pv.Service == service).ToArray();

                var primaryPv = VideoServiceHelper.PrimaryPV(pvs, service);

                return primaryPv != null ? new PVContract(primaryPv) : null;
            }));
        }
예제 #9
0
        public SongForApiContract GetByPV(
            PVService pvService,
            string pvId,
            SongOptionalFields fields      = SongOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            var song = service.GetSongWithPV(s => new SongForApiContract(s, null, lang, fields), pvService, pvId);

            return(song);
        }
예제 #10
0
        public T GetSongWithPV <T>(Func <Song, T> fac, PVService service, string pvId)
            where T : class
        {
            return(HandleQuery(session => {
                var pv = session.Query <PVForSong>()
                         .FirstOrDefault(p => p.Service == service && p.PVId == pvId && !p.Song.Deleted);

                return (pv != null ? fac(pv.Song) : null);
            }));
        }
예제 #11
0
        public ActionResult ByPVBase(PVService? service, string pvId, string callback,
            DataFormat format = DataFormat.Auto)
        {
            if (service == null)
                return HttpStatusCodeResult(HttpStatusCode.BadRequest, "Service not specified or invalid");

            var song = Service.GetSongWithPV(s => new EntryBaseContract(s), service.Value, pvId);

            return Object(song, format, callback);
        }
예제 #12
0
        private VideoUrlParseResult(string url, PVService service, string id, VideoTitleParseResult meta)
        {
            Url = url;
            Service = service;
            Id = id;
            Title = meta.Title ?? string.Empty;
            Author = meta.Author ?? string.Empty;
            ThumbUrl = meta.ThumbUrl ?? string.Empty;

            ResultType = VideoUrlParseResultType.Ok;
        }
예제 #13
0
        private VideoUrlParseResult(string url, PVService service, string id, VideoTitleParseResult meta)
        {
            Url      = url;
            Service  = service;
            Id       = id;
            Title    = meta.Title ?? string.Empty;
            Author   = meta.Author ?? string.Empty;
            ThumbUrl = meta.ThumbUrl ?? string.Empty;

            ResultType = VideoUrlParseResultType.Ok;
        }
예제 #14
0
 public static VideoUrlParseResult VideoUrlParseResultWithTitle(
     string url        = "http://nicovideo.jp/watch/sm1234567",
     PVService service = PVService.NicoNicoDouga,
     string id         = "sm1234567",
     string title      = "Resistance",
     string author     = "tripshots",
     string thumbUrl   = "",
     int?length        = null,
     string[] tags     = null)
 {
     return(VideoUrlParseResult.CreateOk(url, service, id, VideoTitleParseResult.CreateSuccess(title, author, thumbUrl, length, tags)));
 }
예제 #15
0
		public static VideoUrlParseResult VideoUrlParseResultWithTitle(
			string url = "http://nicovideo.jp/watch/sm1234567", 
			PVService service = PVService.NicoNicoDouga, 
			string id = "sm1234567",
			string title = "Resistance",
			string author = "tripshots",
			string thumbUrl = "",
			int? length = null,
			string[] tags = null) {
			
			return VideoUrlParseResult.CreateOk(url, service, id, VideoTitleParseResult.CreateSuccess(title, author, thumbUrl, length, tags));

		}
예제 #16
0
        public ActionResult ByPV(PVService? service, string pvId, ContentLanguagePreference? lang, string callback,
            bool includeAlbums = true, bool includeArtists = true, bool includeNames = true, bool includePVs = false,
            bool includeTags = true, bool includeWebLinks = false,
            DataFormat format = DataFormat.Auto)
        {
            if (service == null)
                return HttpStatusCodeResult(HttpStatusCode.BadRequest, "Service not specified or invalid");

            var song = Service.GetSongWithPV(s => new SongForApiContract(s, null, lang ?? ContentLanguagePreference.Default,
                includeAlbums, includeArtists, includeNames, includePVs, includeTags, true, includeWebLinks), service.Value, pvId);

            return Object(song, format, callback);
        }
예제 #17
0
        public ActionResult PVRedirect(PVService service, string pvId)
        {
            var song = Service.GetSongWithPV(service, pvId);

            if (song == null)
            {
                TempData.SetWarnMessage("Sorry, song not found! Maybe it hasn't been added yet.");
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Details", new { id = song.Id }));
            }
        }
예제 #18
0
        private VideoUrlParseResult(string url, PVService service, string id, VideoTitleParseResult meta)
        {
            Url           = url;
            Service       = service;
            Id            = id;
            Title         = meta.Title ?? string.Empty;
            Author        = meta.Author ?? string.Empty;
            AuthorId      = meta.AuthorId ?? string.Empty;
            ThumbUrl      = meta.ThumbUrl ?? string.Empty;
            LengthSeconds = meta.LengthSeconds;
            Tags          = meta.Tags;
            UploadDate    = meta.UploadDate;

            ResultType = VideoUrlParseResultType.Ok;
        }
예제 #19
0
        public static string VideoServiceLinkUrl(this IHtmlHelper htmlHelper, PVService service)
        {
            // Code from: https://stackoverflow.com/questions/38865163/how-to-get-the-urlhelper-from-html-helper-context-in-asp-net-core-mvc-html-helpe/51519624#51519624
            var urlHelperFactory = htmlHelper.ViewContext.HttpContext.RequestServices.GetRequiredService <IUrlHelperFactory>();
            var urlHelper        = urlHelperFactory.GetUrlHelper(htmlHelper.ViewContext);

            return(service switch
            {
                PVService.Bandcamp => urlHelper.Content("~/Content/ExtIcons/bandcamp.png"),
                PVService.Bilibili => urlHelper.Content("~/Content/ExtIcons/bilibili.png"),
                PVService.File or PVService.LocalFile => urlHelper.Content("~/Content/Icons/music.png"),
                PVService.NicoNicoDouga => urlHelper.Content("~/Content/nico.png"),
                PVService.Piapro => urlHelper.Content("~/Content/ExtIcons/piapro.png"),
                PVService.SoundCloud => urlHelper.Content("~/Content/Icons/soundcloud.png"),
                PVService.Youtube => urlHelper.Content("~/Content/youtube.png"),
                PVService.Vimeo => urlHelper.Content("~/Content/ExtIcons/vimeo.png"),
                PVService.Creofuga => urlHelper.Content("~/Content/ExtIcons/creofuga.png"),
                _ => string.Empty,
            });
예제 #20
0
        public int DeletePVsByAuthor(string author, PVService service)
        {
            PermissionContext.VerifyPermission(PermissionToken.BulkDeletePVs);

            if (string.IsNullOrEmpty(author))
            {
                return(0);
            }

            return(HandleTransaction(session => {
                AuditLog(string.Format("deleting PVs by '{0}' for service {1}.", author, service), session);

                var pvs = session.Query <PVForSong>().Where(p => p.Service == service && p.Author == author).ToArray();

                foreach (var pv in pvs)
                {
                    pv.OnDelete();
                    session.Delete(pv);
                }

                return pvs.Length;
            }));
        }
예제 #21
0
		public VideoServicePiapro(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers) 
			: base(service, parser, linkMatchers) {}
예제 #22
0
 public static bool ShowExternalSiteLink(PVService service)
 {
     return(!servicesWithoutExternalSiteLink.Contains(service));
 }
예제 #23
0
파일: PV.cs 프로젝트: rijuntun/vocadb
 public static string GetUrl(PVService service, string pvId)
 {
     return(VideoServiceHelper.Services[service].GetUrlById(pvId));
 }
예제 #24
0
        public ActionResult PVRedirect(PVService service, string pvId)
        {
            var song = Service.GetSongWithPV(service, pvId);

            if (song == null) {

                TempData.SetWarnMessage("Sorry, song not found! Maybe it hasn't been added yet.");
                return RedirectToAction("Index", "Home");

            } else {

                return RedirectToAction("Details", new { id = song.Id });

            }
        }
예제 #25
0
        public string GetPVId(int id, PVService service)
        {
            var pv = queries.PVForSongAndService(id, service);

            return(pv.PVId);
        }
예제 #26
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
     }));
 }
예제 #27
0
 public SongWithAlbumContract GetSongWithPVAndAlbum(PVService service, string pvId)
 {
     return(GetSongWithPV(s => new SongWithAlbumContract(s, PermissionContext.LanguagePreference), service, pvId));
 }
예제 #28
0
 public static string GetUrl(PVService service, string pvId, PVExtendedMetadata extendedMetadata = null)
 {
     return(VideoServiceHelper.Services[service].GetUrlById(pvId, extendedMetadata));
 }
예제 #29
0
 protected VideoService(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers)
 {
     Service = service;
     this.parser = parser;
     this.linkMatchers = linkMatchers;
 }
예제 #30
0
        public SongForApiContract GetByPV(
            PVService pvService,
            string pvId,
            SongOptionalFields fields = SongOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            var song = service.GetSongWithPV(s => new SongForApiContract(s, null, lang, fields), pvService, pvId);

            return song;
        }
예제 #31
0
 private void CreatePV(PVService service)
 {
     song.CreatePV(new PVContract {
         Service = service, PVId = "test", Name = "test"
     });
 }
예제 #32
0
 protected VideoService(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers)
 {
     Service           = service;
     this.parser       = parser;
     this.linkMatchers = linkMatchers;
 }
예제 #33
0
 private void CreatePV(PVService service)
 {
     song.CreatePV(new PVContract { Service = service, PVId = "test", Name = "test" });
 }
예제 #34
0
		public VideoServiceSoundCloud(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers) 
			: base(service, parser, linkMatchers) {}
예제 #35
0
 public VideoServicePiapro(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers)
     : base(service, parser, linkMatchers)
 {
 }
예제 #36
0
 public PVServiceIconViewModel(PVService service)
 {
     Service = service;
 }
예제 #37
0
 public SongWithAlbumContract GetSongWithPV(PVService service, string pvId)
 {
     return Services.Songs.GetSongWithPVAndAlbum(service, pvId);
 }
예제 #38
0
 public SongWithAdditionalNamesContract GetSongWithPV(PVService service, string pvId)
 {
     return(Services.Songs.GetSongWithPV(service, pvId));
 }
예제 #39
0
 public bool IsValidFor(PVService service)
 {
     return (service == Service);
 }
예제 #40
0
        /// <summary>
        /// Returns PV player HTML by song Id and PV service. Primary PV of that type will be selected.
        /// </summary>
        public ActionResult PVForSongAndService(int songId = invalidId, PVService? service = null)
        {
            if (songId == invalidId)
                return NoId();

            if (service == null)
                return NoId();

            var pv = queries.PVForSongAndService(songId, service.Value);
            return PartialView("PVs/_PVEmbedDynamic", pv);
        }
예제 #41
0
 public VideoServiceSoundCloud(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers)
     : base(service, parser, linkMatchers)
 {
 }
예제 #42
0
 public ImportedSongInListContract(PVService service, string pvId)
 {
     PVService = service;
     PVId      = pvId;
 }
예제 #43
0
        public virtual bool HasPV(PVService service, string pvId)
        {
            ParamIs.NotNullOrEmpty(() => pvId);

            return(PVs.Any(p => p.Service == service && p.PVId == pvId));
        }
예제 #44
0
 public static VideoUrlParseResult CreateOk(string url, PVService service, string id, VideoTitleParseResult meta)
 {
     return new VideoUrlParseResult(url, service, id, meta);
 }
예제 #45
0
 public SongWithAlbumContract GetSongWithPV(PVService service, string pvId)
 {
     return(songService.GetSongWithPVAndAlbum(service, pvId));
 }
예제 #46
0
 public SongWithAdditionalNamesContract GetSongWithPV(PVService service, string pvId)
 {
     return Services.Songs.GetSongWithPV(service, pvId);
 }
예제 #47
0
 public static VideoUrlParseResult CreateOk(string url, PVService service, string id, VideoTitleParseResult meta)
 {
     return(new VideoUrlParseResult(url, service, id, meta));
 }
예제 #48
0
 public string GetPVId(int songId, PVService service)
 {
     var pv = queries.PVForSongAndService(songId, service);
     return pv.PVId;
 }