public ITrack Convert(SavedTrack source, ITrack destination, ResolutionContext context) { var albunsArtists = source.Track.Album.Artists.Select(i => new Artist { Id = i.Id, Name = i.Name }); var albunsImages = source.Track.Album.Images.Select(i => new Image { Url = i.Url, Height = i.Height, Width = i.Width }); var album = new Album { Id = source.Track.Album.Id, Name = source.Track.Album.Name, Images = albunsImages.ToArray <IImage>(), Artists = albunsArtists.ToArray <IArtist>(), }; var externalUrl = new ExternalUrl { Spotify = source.Track.ExternUrls[nameof(Spotify)] }; return(new Track { Id = source.Track.Id, Album = album, Url = externalUrl }); }
private void ProxyHttpLiveIndex(string identifier, string source) { Log.Debug("HLS: Using Proxied streaming mode with playlist at {0}", source); WebRequest request = WebRequest.Create(source); request.Headers.Add("X-Forwarded-For", HttpContext.Request.UserHostAddress); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string playlistContents = reader.ReadToEnd(); string prefix = HttpLiveUrls[identifier].Substring(0, HttpLiveUrls[identifier].IndexOf("/stream/") + 8); string newPlaylist = playlistContents.Split('\n') .Select(line => { if (!line.Trim().StartsWith(prefix)) { return(line.Trim()); } var queryString = HttpUtility.ParseQueryString(new Uri(line.Trim()).Query); return(Url.Action("ProxyHttpLiveSegment", "Stream", new RouteValueDictionary(new { identifier = identifier, ctdAction = queryString["action"], parameters = queryString["parameters"] }), ExternalUrl.GetScheme(Request.Url), ExternalUrl.GetHost(Request.Url))); }) .Join(Environment.NewLine); Response.ContentType = response.ContentType; Response.Write(newPlaylist); Response.Flush(); }
public override int GetHashCode() { return(Name.GetHashCode() + Price.GetHashCode() + ExternalUrl.GetHashCode() + ImageUrl.GetHashCode()); }
public static string AbsoluteAction(this UrlHelper helper, string actionName, string controllerName = null, RouteValueDictionary routeValues = null) { var request = helper.RequestContext.HttpContext.Request; var path = helper.Action(actionName, controllerName, routeValues); return(String.Format("{0}://{1}{2}", ExternalUrl.GetScheme(request), ExternalUrl.GetHost(request), path)); }
protected StreamType GetStreamMode() { if (Settings.ActiveSettings.StreamType != StreamType.DirectWhenPossible) { return(Settings.ActiveSettings.StreamType); } return(NetworkInformation.IsLocalAddress(ExternalUrl.GetOnlyHostname(Request)) && NetworkInformation.IsOnLAN(HttpContext.Request.UserHostAddress) ? StreamType.Direct : StreamType.Proxied); }
private List <ExternalUrl> GetExternalUrls() { List <ExternalUrl> externalUrlsList = new List <ExternalUrl>(); foreach (string item in this.externalUrls) { ExternalUrl url = new ExternalUrl(item, this.Name); externalUrlsList.Add(url); } return(externalUrlsList); }
public async Task AsyncDeserializeTest() { ExternalUrl test = new ExternalUrl { Key = "abc", Value = "qwe" }; var testSerialized = await Helper.SerializeObjectAsync(test); var resulting = await Helper.DeserializeStringAsync <ExternalUrl>(testSerialized); Assert.Equal(test.Key, resulting.Key); Assert.Equal(test.Value, resulting.Value); }
public async Task <bool> ReadExternalFile(string extUrl = null, string fileName = null) { if (!string.IsNullOrWhiteSpace(extUrl)) { ExternalUrl = extUrl; } if (!string.IsNullOrWhiteSpace(fileName)) { FileName = fileName; } if (string.IsNullOrWhiteSpace(ExternalUrl) || string.IsNullOrWhiteSpace(FileName)) { throw new InvalidOperationException("External URL or File Name not set"); } if (ExternalUrl.StartsWith("ftp", StringComparison.CurrentCulture)) { return(await GetFtpData()); } return(await GetHttpData()); }
public override int GetHashCode() { unchecked { var hashCode = Attributes != null?Attributes.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (CatalogVisibility != null ? CatalogVisibility.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Categories != null ? Categories.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExternalUrl != null ? ExternalUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Featured.GetHashCode(); hashCode = (hashCode * 397) ^ Id; hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0); hashCode = (hashCode * 397) ^ InStock.GetHashCode(); hashCode = (hashCode * 397) ^ ManageStock.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OnSale.GetHashCode(); hashCode = (hashCode * 397) ^ ParentId; hashCode = (hashCode * 397) ^ (Permalink != null ? Permalink.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PriceHtml != null ? PriceHtml.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Purchasable.GetHashCode(); hashCode = (hashCode * 397) ^ (RegularPrice != null ? RegularPrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RelatedIds != null ? RelatedIds.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SalePrice != null ? SalePrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ShortDescription != null ? ShortDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Slug != null ? Slug.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (StockQuantity != null ? StockQuantity.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TaxClass != null ? TaxClass.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TaxStatus != null ? TaxStatus.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TotalSales; hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Virtual.GetHashCode(); return(hashCode); } }
public void AddCardWidgetOnPageTemplate() { BAT.Macros().NavigateTo().Design().PageTemplates(this.Culture); BAT.Wrappers().Backend().PageTemplates().PageTemplateMainScreen().OpenTemplateEditor(PageTemplateName); BATFeather.Wrappers().Backend().Pages().PageZoneEditorWrapper().AddWidgetToPlaceHolderPureMvcMode(WidgetName, "Body"); BATFeather.Wrappers().Backend().Pages().PageZoneEditorWrapper().EditWidget(WidgetName); BATFeather.Wrappers().Backend().Card().CardWrapper().FillHeadingText(HeadingText); BATFeather.Wrappers().Backend().Card().CardWrapper().FillTextArea(TextArea); BATFeather.Wrappers().Backend().Card().CardWrapper().ClickSelectImageButton(); BATFeather.Wrappers().Backend().Media().MediaSelectorWrapper().WaitForContentToBeLoaded(isEmptyScreen: false); BATFeather.Wrappers().Backend().Media().MediaSelectorWrapper().SelectMediaFile(ImageTitle); BATFeather.Wrappers().Backend().Widgets().SelectorsWrapper().DoneSelecting(); BATFeather.Wrappers().Backend().Card().CardWrapper().FillLabel(LabelText); BATFeather.Wrappers().Backend().Card().CardWrapper().SelectExternalUrlOption(); BATFeather.Wrappers().Backend().Card().CardWrapper().FillExternalUrl(ExternalUrl); BATFeather.Wrappers().Backend().Widgets().WidgetDesignerWrapper().SaveChanges(); BAT.Wrappers().Backend().PageTemplates().PageTemplateModifyScreen().PublishTemplate(); BAT.Macros().NavigateTo().CustomPage("~/" + PageName.ToLower(), false, this.Culture); BATFeather.Wrappers().Frontend().Card().CardWrapper().VerifyCardWidgetContentOnFrontend(HeadingText); BATFeather.Wrappers().Frontend().Card().CardWrapper().VerifyCardWidgetContentOnFrontend(TextArea); BATFeather.Wrappers().Frontend().Card().CardWrapper().VerifyImageIsPresentOnFrontend(ImageTitle); BATFeather.Wrappers().Frontend().Card().CardWrapper().VerifyCardWidgetContentOnFrontend(LabelText); BATFeather.Wrappers().Frontend().Card().CardWrapper().VerifyPageIsPresentOnFrontend(LabelText, ExternalUrl.ToLower()); }
public ActionResult Playlist(WebMediaType type, string itemId, string transcoder = null) { if (!PlayerOpenedBy.Contains(Request.UserHostAddress)) { PlayerOpenedBy.Add(Request.UserHostAddress); } var profile = GetProfile(GetStreamControl(type), transcoder ?? GetDefaultProfile(type)); StringBuilder m3u = new StringBuilder(); m3u.AppendLine("#EXTM3U"); RouteValueDictionary parameters; string continuationId = "playlist-" + randomGenerator.Next(10000, 99999); string url; int filecount = 1; switch (type) { case WebMediaType.MusicAlbum: // add all album tracks foreach (WebMusicTrackBasic track in Connections.Current.MAS.GetMusicTracksBasicForAlbum(Settings.ActiveSettings.MusicProvider, itemId, sort: WebSortField.MusicTrackNumber)) { parameters = new RouteValueDictionary(); parameters["item"] = track.Id; parameters["transcoder"] = profile.Name; parameters["continuationId"] = continuationId; m3u.AppendLine(String.Format("#EXTINF:{0},{1}", track.Duration, track.Title)); url = Url.Action(Enum.GetName(typeof(WebMediaType), WebMediaType.MusicTrack), "Stream", parameters, ExternalUrl.GetScheme(Request.Url), ExternalUrl.GetHost(Request.Url)); m3u.AppendLine(url); } break; case WebMediaType.MusicTrack: case WebMediaType.TVEpisode: case WebMediaType.Movie: var mediaItem = Connections.Current.MAS.GetMediaItem(GetProvider(type), type, itemId); filecount = mediaItem.Path.Count; goto case WebMediaType.Recording; // really, Microsoft? Fall-through cases are useful. case WebMediaType.TV: case WebMediaType.Recording: for (int i = 0; i < filecount; i++) { parameters = new RouteValueDictionary(); parameters["item"] = itemId; parameters["transcoder"] = profile.Name; parameters["continuationId"] = continuationId; parameters["fileindex"] = i; url = Url.Action(Enum.GetName(typeof(WebMediaType), type), "Stream", parameters, ExternalUrl.GetScheme(Request.Url), ExternalUrl.GetHost(Request.Url)); m3u.AppendLine("#EXTINF:-1, " + MediaName.GetMediaName(type, itemId)); m3u.AppendLine(url); } break; default: Log.Error("Requested playlist for non-supported media type {0} with id {1}", type, itemId); break; } // return it byte[] data = Encoding.UTF8.GetBytes(m3u.ToString()); return(File(data, "audio/x-mpegurl", "stream.m3u")); }