Ejemplo n.º 1
0
        public Site(OnlineVideos.Sites.SiteUtilBase siteUtil)
        {
            Model = siteUtil;

            Name = siteUtil.Settings.Name;
            Language = siteUtil.Settings.Language;
            Description = siteUtil.Settings.Description;
        }
Ejemplo n.º 2
0
        public GlobalSite(OnlineVideos.OnlineVideosWebservice.Site site)
        {
            Model = site;
            Other = Model;

            Owner = Model.Owner_FK.Substring(0, Model.Owner_FK.IndexOf('@')).Replace('.', ' ').Replace('_', ' ');
            Language = Util.GetLocalizedLanguageDisplayName(site.Language);

            ThumbnailImage = Path.Combine(OnlineVideos.OnlineVideoSettings.Instance.ThumbsDir, @"Icons\" + site.Name + ".png");
            Thumb = "http://onlinevideos.nocrosshair.de/Icons/" + site.Name + ".png";
        }
Ejemplo n.º 3
0
 public override string GetVideoUrl(OnlineVideos.VideoInfo video)
 {
     if (video.VideoUrl.Contains("/vp/"))
     {
         return String.Format(videoUrlFormatString, video.VideoUrl.Substring(video.VideoUrl.LastIndexOf("#") + 1));
     }
     else
     {
         return String.Format(videoUrlFormatString, new Uri(video.VideoUrl).Segments.Last().Trim('/'));
     }
 }
Ejemplo n.º 4
0
        public Category(OnlineVideos.Category category)
        {
            Model = category;

            Name = category.Name;
            Description = category.Description;
            ThumbnailImage = category.ThumbnailImage;
            CategoryPath = category.RecursiveName();
            if (category is OnlineVideos.RssLink) EstimatedVideoCount = (category as OnlineVideos.RssLink).EstimatedVideoCount;

            // we cannot attach directly to the PropertyChanged event of the Model as it is in another domain and PropertyChangedEventArgs is not serializable
            eventDelegator = OnlineVideosAppDomain.Domain.CreateInstanceAndUnwrap(typeof(PropertyChangedDelegator).Assembly.FullName, typeof(PropertyChangedDelegator).FullName) as PropertyChangedDelegator;
            eventDelegator.InvokeTarget = new PropertyChangedExecutor() { InvokeHandler = ModelPropertyChanged };
            Model.PropertyChanged += eventDelegator.EventDelegate;
        }
Ejemplo n.º 5
0
        public async Task SearchAsync(string term)
        {
            if (string.IsNullOrEmpty(term))
            {
                ToastManager.ShowError("Please enter something.");
                return;
            }

            SetMessage(Core.StringMessage.LoadingPleaseWait);
            if (!App.Locator.Network.IsActive)
            {
                SetMessage(Core.StringMessage.NoInternetConnection);
                return;
            }


            foundInViez = false;
            IsLoading   = true;

            try
            {
                ClearSearchViewModelData();

                var tasks = new List <Task>
                {
                    Task.Run(
                        async() =>
                    {
                        _tracksResponse = await _service.SearchTracksAsync(term, limit: 20);
                        if (_tracksResponse != null)
                        {
                            await DispatcherHelper.RunAsync(
                                () =>
                            {
                                int indexToAdd = -1;
                                Tracks         = CreateLastIncrementalCollection(
                                    "songs",
                                    () => _tracksResponse,
                                    tracks => _tracksResponse = tracks,
                                    async i => await _service.SearchTracksAsync(term, page: i, limit: 20));


                                foreach (var addedOTrack in _tracksResponse.Content)
                                {
                                    indexToAdd++;

                                    Tracks.Add(Data.Model.WebSongConverter.CreateSong(addedOTrack));
                                    if (indexToAdd == 2 || indexToAdd == 10 || indexToAdd == 22 || indexToAdd == 34 || indexToAdd == 49 ||
                                        indexToAdd == 63 || indexToAdd == 78 || indexToAdd == 88 || indexToAdd == 99)
                                    {
                                        Tracks.Insert(indexToAdd, new ListAdvert());
                                    }
                                }
                            });
                        }
                    }),



                    Task.Run(
                        async() =>
                    {
                        _albumsResponse = await _service.SearchAlbumsAsync(term, limit: 20);
                        if (_albumsResponse != null)
                        {
                            await DispatcherHelper.RunAsync(
                                () =>
                            {
                                int indexToAdd = -1;

                                Albums = CreateLastIncrementalCollection(
                                    "albums",
                                    () => _albumsResponse,
                                    albums => _albumsResponse = albums,
                                    async i => await _service.SearchAlbumsAsync(term, page: i, limit: 20));

                                foreach (var addedOAlbum in _albumsResponse?.Content)
                                {
                                    if (!string.IsNullOrEmpty(addedOAlbum.Mbid) || !string.IsNullOrEmpty(addedOAlbum.Id))
                                    {
                                        indexToAdd++;
                                        Albums.Add(Data.Model.WebSongConverter.CreateAlbum(addedOAlbum));
                                        if (indexToAdd == 2 || indexToAdd == 10 || indexToAdd == 22 || indexToAdd == 34 || indexToAdd == 49 ||
                                            indexToAdd == 63 || indexToAdd == 78 || indexToAdd == 88 || indexToAdd == 99)
                                        {
                                            Albums.Insert(indexToAdd, new Advert());
                                        }
                                    }
                                }
                            });
                        }
                    }),


                    Task.Run(
                        async() =>
                    {
                        _artistsResponse = await _service.SearchArtistsAsync(term, limit: 1);
                        if (_artistsResponse != null && _artistsResponse.Content.Count > 0)
                        {
                            await DispatcherHelper.RunAsync(() => Artists = new List <LastArtist>(_artistsResponse.Content));
                        }
                    }),


                    Task.Run(
                        async() =>
                    {
                        try
                        {
                            await Task.Factory.StartNew(async() =>
                            {
                                await DispatcherHelper.RunAsync(async() =>
                                {
                                    if (App.Locator.Setting.VideoOnOff)
                                    {
                                        VideoMessage = Core.StringMessage.LoadingPleaseWait;
                                        OnlineVideos = await _misc.GetSearchedVideos(20, term);
                                        if (OnlineVideos != null && OnlineVideos.CountOrDefault() > 0)
                                        {
                                            VideoMessage = Core.StringMessage.NoMessge;
                                        }
                                        else
                                        {
                                            VideoMessage = Core.StringMessage.EmptyMessage;
                                        }
                                    }
                                    else
                                    {
                                        VideoMessage = Core.StringMessage.NoMessge;
                                    }
                                });
                            });
                        }

                        catch
                        {
                            VideoMessage = Core.StringMessage.SomethinWentWrong;
                        }
                    })
                };
                await Task.WhenAll(tasks);
            }
            catch
            {
                SetMessage(Core.StringMessage.SomethinWentWrong);
            }

            if (Tracks == null || Tracks.Count < 1)
            {
                await FindOnViez(term);
            }
            else
            {
                TrackMessage = (Tracks != null && Tracks.Count > 0) ? Core.StringMessage.NoMessge : Core.StringMessage.EmptyMessage;
            }

            if ((Albums != null && Albums.Count > 0) && (Artists != null && Artists.Count > 0))
            {
                ArtistHeader = true;
            }
            else
            {
                ArtistHeader = false;
            }

            AlbumArtistMessage = ((Albums != null && Albums.Count > 0) || (Artists != null && Artists.Count > 0)) ? Core.StringMessage.NoMessge : Core.StringMessage.EmptyMessage;

            IsLoading = false;
        }
        private void Play_Step6(PlayListItem playItem, string lsUrl, OnlineVideos.MediaPortal1.Player.PlayerFactory factory)
        {
            IPlayerFactory savedFactory = g_Player.Factory;
            g_Player.Factory = factory;
            try
            {
                if (factory.PreparedPlayer is OnlineVideosPlayer)
                    g_Player.Play("http://localhost/OnlineVideo.mp4", g_Player.MediaType.Video); // hack to get around the MP 1.3 Alpha bug with non http URLs
                else
                    g_Player.Play(lsUrl, g_Player.MediaType.Video);
            }
            catch (Exception ex) // since many plugins attach to the g_Player.PlayBackStarted event, this might throw unexpected errors
            {
                Log.Instance.Warn(ex.ToString());
            }
            g_Player.Factory = savedFactory;

            if (g_Player.Player != null && g_Player.HasVideo)
            {
                if (!string.IsNullOrEmpty(playItem.Video.StartTime))
                {
                    Log.Instance.Info("Found starttime: {0}", playItem.Video.StartTime);
                    double seconds = Helpers.TimeUtils.SecondsFromTime(playItem.Video.StartTime);
                    if (seconds > 0.0d)
                    {
                        Log.Instance.Info("SeekingAbsolute: {0}", seconds);
                        g_Player.SeekAbsolute(seconds);
                    }
                }
                playItem.FileName = lsUrl;
                currentPlayingItem = playItem;
                SetGuiProperties_PlayingVideo(playItem);
            }
        }
        void Play_Step5(PlayListItem playItem, string lsUrl, bool goFullScreen, OnlineVideos.MediaPortal1.Player.PlayerFactory factory, bool? factoryPrepareResult, bool showMessage)
        {
            if (factoryPrepareResult == null)
            {
                if (factory.PreparedPlayer is OnlineVideosPlayer && (factory.PreparedPlayer as OnlineVideosPlayer).BufferingStopped == true) showMessage = false;
                factory.PreparedPlayer.Dispose();
                if (showMessage)
                {
                    GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    if (dlg != null)
                    {
                        dlg.Reset();
                        dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                        dlg.SetHeading(Translation.Instance.Error);
                        dlg.SetText(Translation.Instance.UnableToPlayVideo);
                        dlg.DoModal(GUIWindowManager.ActiveWindow);
                    }
                }
            }
            else
            {
                (factory.PreparedPlayer as OVSPLayer).GoFullscreen = goFullScreen;

                Uri subtitleUri = null;
                bool validUri = !String.IsNullOrEmpty(playItem.Video.SubtitleUrl) && Uri.TryCreate(playItem.Video.SubtitleUrl, UriKind.Absolute, out subtitleUri);

                if (!string.IsNullOrEmpty(playItem.Video.SubtitleText) || (validUri && !subtitleUri.IsFile))
                {
                    // download subtitle file before starting playback
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
                    {
                        string subs = string.IsNullOrEmpty(playItem.Video.SubtitleText) ? WebCache.Instance.GetWebData(playItem.Video.SubtitleUrl) : playItem.Video.SubtitleText;
                        if (!string.IsNullOrEmpty(subs))
                        {
                            string subFile = Path.Combine(Path.GetTempPath(), "OnlineVideoSubtitles.txt");
                            File.WriteAllText(subFile, subs, System.Text.Encoding.UTF8);
                            (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subFile;
                        }
                        return true;
                    },
                    delegate(bool success, object result)
                    {
                        Play_Step6(playItem, lsUrl, factory);
                    },
                    Translation.Instance.DownloadingSubtitle, true);
                }
                else
                {
                    if (validUri && subtitleUri.IsFile)
                        (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subtitleUri.AbsolutePath;
                    Play_Step6(playItem, lsUrl, factory);
                }
            }
        }
Ejemplo n.º 8
0
 public override List<ContextMenuEntry> GetContextMenuEntries(Category selectedCategory, OnlineVideos.VideoInfo selectedItem)
 {
     List<ContextMenuEntry> result = new List<ContextMenuEntry>();
     if (selectedItem != null && !string.IsNullOrEmpty(selectedItem.Other as string))
     {
         result.Add(new ContextMenuEntry() { DisplayText = "Mehr " + selectedItem.Description, Other = selectedItem.Other });
     }
     return result;
 }
Ejemplo n.º 9
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, OnlineVideos.VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (choice != null && choice.DisplayText.StartsWith("Mehr "))
     {
         currentVideoTitle = choice.DisplayText;
         return new ContextMenuExecutionResult()
             { ResultItems =
                 GetVideosFromApiUrl(GetApiUrl("myvideo.videos.list_by_user", new NameValueCollection() { { "user", choice.Other as string } }))
                     .ConvertAll<SearchResultItem>(v => v as SearchResultItem) };
     }
     return null;
 }
Ejemplo n.º 10
0
		public static SiteSettings GetRemoteSite(string siteName, OnlineVideos.OnlineVideosWebservice.OnlineVideosService ws = null)
		{
			try
			{
				if (ws == null) ws = new OnlineVideosService() { Timeout = 30000, EnableDecompression = true };
				string siteXml = ws.GetSiteXml(siteName);
				if (siteXml.Length > 0)
				{
                    IList<SiteSettings> sitesFromWeb = SerializableSettings.Deserialize(siteXml);
					if (sitesFromWeb != null && sitesFromWeb.Count > 0)
					{
						// Download images
						try
						{
							string iconPath = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, @"Icons\" + siteName + ".png");
							byte[] icon = ws.GetSiteIconIfChanged(siteName,
								File.Exists(iconPath) ?
									BitConverter.ToString(md5Service.ComputeHash(File.ReadAllBytes(iconPath))).Replace("-", "").ToLower()
									:
									null);
							if (icon != null && icon.Length > 0) File.WriteAllBytes(iconPath, icon);
						}
						catch (Exception ex)
						{
							OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting Icon for Site '{0}': {1}", siteName, ex.ToString());
						}
						try
						{
							string bannerPath = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, @"Banners\" + siteName + ".png");
							byte[] banner = ws.GetSiteBannerIfChanged(siteName,
								File.Exists(bannerPath) ?
									BitConverter.ToString(md5Service.ComputeHash(File.ReadAllBytes(bannerPath))).Replace("-", "").ToLower()
									:
									null);
							if (banner != null && banner.Length > 0) File.WriteAllBytes(bannerPath, banner);
						}
						catch (Exception ex)
						{
							OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting Banner for Site '{0}': {1}", siteName, ex.ToString());
						}

						// return the site
						return sitesFromWeb[0];
					}
				}
			}
			catch (Exception ex)
			{
				OnlineVideos.OnlineVideoSettings.Instance.Logger.Warn("Error getting remote Site {0}: {1}", siteName, ex.ToString());
			}
			return null;
		}
Ejemplo n.º 11
0
        public override string GetVideoUrl(OnlineVideos.VideoInfo video)
        {
            video.PlaybackOptions = new Dictionary<string, string>();
            var tokenDataJson = GetWebData<JToken>(string.Format(tokenUrl, video.VideoUrl));
            var token= tokenDataJson["token"];
            var sig = tokenDataJson["sig"];
            string hlsPlaylistUrl = string.Format(playlistUrl, video.VideoUrl, HttpUtility.UrlEncode(token.ToString()), sig);
            var m3u8Data = GetWebData(hlsPlaylistUrl);
            foreach (Match match in Regex.Matches(m3u8Data, m3u8Regex))
            {
                video.PlaybackOptions.Add(
                    string.Format("{0} - {1} kbps", match.Groups["quality"].Value, int.Parse(match.Groups["bitrate"].Value) / 1000),
                    match.Groups["url"].Value);
            }

            return video.PlaybackOptions.Select(p => p.Value).FirstOrDefault();
        }
        void Play_Step5(PlayListItem playItem, string lsUrl, bool goFullScreen, OnlineVideos.MediaPortal1.Player.PlayerFactory factory, bool? factoryPrepareResult, bool showMessage)
        {
            if (factoryPrepareResult == null)
            {
                if (factory.PreparedPlayer is OnlineVideosPlayer && (factory.PreparedPlayer as OnlineVideosPlayer).BufferingStopped == true) showMessage = false;
                factory.PreparedPlayer.Dispose();
                if (showMessage)
                {
                    DisplayUnableToPlayDialog();
                }
            }
            else
            {
                (factory.PreparedPlayer as OVSPLayer).GoFullscreen = goFullScreen;

                Uri subtitleUri = null;
                bool validUri = !String.IsNullOrEmpty(playItem.Video.SubtitleUrl) && Uri.TryCreate(playItem.Video.SubtitleUrl, UriKind.Absolute, out subtitleUri);

                if (!string.IsNullOrEmpty(playItem.Video.SubtitleText) || (validUri && !subtitleUri.IsFile))
                {
                    // download subtitle file before starting playback
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
                    {
                        string subs = string.IsNullOrEmpty(playItem.Video.SubtitleText) ? WebCache.Instance.GetWebData(playItem.Video.SubtitleUrl) : playItem.Video.SubtitleText;
                        if (!string.IsNullOrEmpty(subs))
                        {
                            string subFile = Path.Combine(Path.GetTempPath(), "OnlineVideoSubtitles.txt");
                            File.WriteAllText(subFile, subs, System.Text.Encoding.UTF8);
                            (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subFile;
                        }
                        return true;
                    },
                    delegate(bool success, object result)
                    {
                        Play_Step6(playItem, lsUrl, factory);
                    },
                    Translation.Instance.DownloadingSubtitle, true);
                }
                else
                {
                    if (validUri && subtitleUri.IsFile)
                        (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subtitleUri.AbsolutePath;
                    Play_Step6(playItem, lsUrl, factory);
                }
            }
        }
Ejemplo n.º 13
0
        public override void Initialize(OnlineVideos.SiteSettings siteSettings)
        {
            base.Initialize(siteSettings);
            if (!string.IsNullOrEmpty(videoListSearchResultsRegEx)) regEx_VideoListSearchResults = new Regex(videoListSearchResultsRegEx, defaultRegexOptions);

        }
Ejemplo n.º 14
0
    public static void LoadAndWaitForMPUrlSourceFilter(string url, OnlineVideos.MPUrlSourceFilter.IFilterStateEx filterStateEx)
    {
      //string url = ApplyMPUrlSourceFilterSiteUserSettings(_resourceAccessor.ResourcePathName);
      int result = filterStateEx.LoadAsync(url);
      if (result < 0)
        throw new UPnPRendererExceptions("Loading URL async error:  {0}", result);

      WaitUntilReady(filterStateEx.IsStreamOpened, 1, "Check stream open error");
      WaitUntilReady(filterStateEx.IsFilterReadyToConnectPins, 50, "IsFilterReadyToConnectPins error");
    }