示例#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" });
 }
		public VideoServiceSoundCloud(PVService service, IVideoServiceParser parser, RegexLinkMatcher[] linkMatchers) 
			: base(service, parser, linkMatchers) {}
 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)
 {
 }
 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;
 }