private System.IO.Stream GetUnsort(int userid, HistoryInfo info)
        {
            PlexObject ret = new PlexObject(PlexHelper.NewMediaContainer(MediaContainerTypes.Video, info, true));

            if (!ret.Init())
            {
                return(new MemoryStream());
            }
            List <Video>         dirs    = new List <Video>();
            VideoLocalRepository repVids = new VideoLocalRepository();
            List <VideoLocal>    vids    = repVids.GetVideosWithoutEpisode();

            foreach (VideoLocal v in vids.OrderByDescending(a => a.DateTimeCreated))
            {
                Video m = new Video();
                try
                {
                    PlexHelper.PopulateVideo(m, v, JMMType.File, userid);
                    m.GrandparentKey = null;
                    if (!string.IsNullOrEmpty(m.Duration))
                    {
                        dirs.Add(m, info);
                    }
                }
                catch (Exception e)
                {
                    //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null)
                }
            }
            ret.Childrens = dirs;
            return(ret.GetStream());
        }
예제 #2
0
        public static void ShowExplorer(PlexObject content)
        => new DataExplorer
        {
            PlexData = content
        }

        .ShowDialog();
예제 #3
0
        public static MediaData DataFromContent(PlexObject content, MyPlex.Server server)
        {
            var contentId               = content.ApiUri;
            var customData              = CustomData.FillFromApiServer(server);
            var contentType             = @"video";
            const StreamType streamType = StreamType.BUFFERED;

            return(new MediaData(contentId, contentType, null, streamType, 0D, customData));
        }
예제 #4
0
파일: Cast.cs 프로젝트: mitchscobell/PlexDL
 /// <summary>
 /// Try and launch the cast window with the specified content
 /// </summary>
 /// <param name="content">The PlexObject to cast</param>
 public static void TryCast(PlexObject content)
 {
     using (var frm = new Cast {
         StreamingContent = content
     })
     {
         frm.ShowDialog();
     }
 }
예제 #5
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (ofdMetadata.ShowDialog() == DialogResult.OK)
     {
         PlexObject obj = Methods.MetadataFromFile(ofdMetadata.FileName);
         StreamingContent = obj;
         flpActors.Controls.Clear();
         PlexDL.WaitWindow.WaitWindow.Show(LoadWorker, "Parsing Metadata");
     }
 }
예제 #6
0
        /// <summary>
        /// Manually specify a server to prefill content data information
        /// </summary>
        /// <param name="content"></param>
        /// <param name="server"></param>
        /// <returns></returns>
        public static MediaData DataFromContent(PlexObject content, MyPlex.Server server)
        {
            //ID of content to play via Plex app
            var contentId = content.ApiUri;

            //custom data filled from Plex server provider
            var customData = CustomData.FillFromApiServer(server);

            //stream constants
            const string     contentType = @"VIDEO";
            const StreamType streamType  = StreamType.BUFFERED;

            //SharpCaster MediaData object provider for streaming media
            return(new MediaData(contentId, contentType, null, streamType, 0D, customData));
        }
예제 #7
0
        public void ExportMetadata(string fileName)
        {
            PlexObject        subReq      = StreamingContent;
            XmlSerializer     xsSubmit    = new XmlSerializer(typeof(PlexObject));
            XmlWriterSettings xmlSettings = new XmlWriterSettings();
            StringWriter      sww         = new StringWriter();

            xmlSettings.Indent             = true;
            xmlSettings.IndentChars        = ("\t");
            xmlSettings.OmitXmlDeclaration = false;

            xsSubmit.Serialize(sww, subReq);

            File.WriteAllText(fileName, sww.ToString());
            MessageBox.Show("Successfully exported metadata!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public System.IO.Stream GetItemsFromGroup(int userid, string GroupId, HistoryInfo info)
        {
            PlexObject ret = new PlexObject(PlexHelper.NewMediaContainer(MediaContainerTypes.Show, info, false));

            if (!ret.Init())
            {
                return(new MemoryStream());
            }
            int groupID;

            int.TryParse(GroupId, out groupID);
            List <Video> retGroups = new List <Video>();

            if (groupID == -1)
            {
                return(new MemoryStream());
            }

            using (var session = JMMService.SessionFactory.OpenSession())
            {
                AnimeGroupRepository repGroups = new AnimeGroupRepository();
                AnimeGroup           grp       = repGroups.GetByID(groupID);
                if (grp != null)
                {
                    Contract_AnimeGroup basegrp = grp.ToContract(grp.GetUserRecord(session, userid));
                    List <AnimeSeries>  sers2   = grp.GetSeries(session);
                    foreach (AnimeGroup grpChild in grp.GetChildGroups())
                    {
                        Video v = StatsCache.Instance.StatPlexGroupsCache[userid][grpChild.AnimeGroupID];
                        if (v != null)
                        {
                            retGroups.Add(v.Clone(), info);
                        }
                    }
                    foreach (AnimeSeries ser in grp.GetSeries())
                    {
                        Contract_AnimeSeries cserie = ser.ToContract(ser.GetUserRecord(session, userid), true);
                        Video v = PlexHelper.FromSerieWithPossibleReplacement(cserie, ser, ser.GetAnime(), userid);
                        v.AirDate = ser.AirDate.HasValue ? ser.AirDate.Value : DateTime.MinValue;
                        v.Group   = basegrp;
                        retGroups.Add(v, info);
                    }
                }
                ret.Childrens = PlexHelper.ConvertToDirectoryIfNotUnique(retGroups.OrderBy(a => a.AirDate).ToList());
                return(ret.GetStream());
            }
        }
예제 #9
0
        public DataSet FromPlexRaw(PlexObject data)
        {
            try
            {
                var doc = data.RawMetadata;

                var sections = new DataSet();
                sections.ReadXml(new XmlNodeReader(doc));

                return(sections);
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, @"ApiExplorerPxzError");
                return(null);
            }
        }
예제 #10
0
        public static bool StreamAdultContentCheck(PlexObject stream)
        {
            if (!ObjectProvider.Settings.Generic.AdultContentProtection)
            {
                return(true);
            }
            if (!AdultKeywordCheck(stream))
            {
                return(true);
            }

            var result =
                UIMessages.Question(
                    @"The content you're about to view may contain adult (18+) themes. Are you okay with viewing this content?",
                    @"Warning");

            return(result);
        }
예제 #11
0
 public static void LaunchBrowser(PlexObject stream)
 {
     try
     {
         if (Methods.StreamAdultContentCheck(stream))
         {
             Process.Start(stream.StreamInformation.Links
                           .View); //normal MP4 stream (this won't trigger a browser download if it's a supported file)
             LoggingHelpers.RecordGeneralEntry("Started streaming " + stream.StreamInformation.ContentTitle +
                                               " (Browser)");
         }
     }
     catch (Exception ex)
     {
         UIMessages.Error("Error occurred whilst trying to launch the default browser\n\n" + ex,
                          @"Launch Error");
         LoggingHelpers.RecordException(ex.Message, "BrowserLaunchError");
     }
 }
예제 #12
0
        public static void LaunchPvs(PlexObject stream)
        {
            if (stream != null)
            {
                try
                {
                    if (!Methods.StreamAdultContentCheck(stream))
                    {
                        return;
                    }

                    //downloads won't work properly if you're streaming at the same time
                    if (!Flags.IsDownloadRunning && !Flags.IsEngineRunning)
                    {
                        var frm = new UI.Forms.Player
                        {
                            StreamingContent = stream
                        };
                        LoggingHelpers.RecordGeneralEntry("Started streaming " + stream.StreamInformation.ContentTitle +
                                                          " (PVS)");
                        frm.ShowDialog();
                    }
                    else
                    {
                        UIMessages.Warning(
                            "You cannot stream \n" + stream.StreamInformation.ContentTitle +
                            "\n because a download is already running. Cancel the download before attempting to stream within PlexDL.",
                            @"Validation Error");
                        LoggingHelpers.RecordGeneralEntry(
                            "Tried to stream content via PVS, but a download is running.");
                    }
                }
                catch (Exception ex)
                {
                    UIMessages.Error("Error occurred whilst trying to launch VLC\n\n" + ex, @"Launch Error");
                    LoggingHelpers.RecordException(ex.Message, "VLCLaunchError");
                }
            }
            else
            {
                LoggingHelpers.RecordGeneralEntry("Tried to stream content via PVS, but one or more values were null.");
            }
        }
예제 #13
0
        public static bool AdultKeywordCheck(PlexObject stream)
        {
            var keywords = Resources.keywordBlacklist.Split('\n');
            //search through content title and plot summary
            var search = stream.StreamInformation.ContentTitle.ToLower() + stream.Synopsis.ToLower();
            var rgx    = new Regex("[^a-zA-Z0-9_. ]+");

            //UIMessages.Info(keywords.Length.ToString());
            search = rgx.Replace(search, "");
            var match = false;

            if (string.Equals(stream.ContentGenre.ToLower(), "p**n") ||
                string.Equals(stream.ContentGenre.ToLower(), "adult"))
            {
                match = true;
            }
            else
            {
                if (keywords.Length <= 0)
                {
                    return(false);
                }

                foreach (var k in keywords)
                {
                    if (!string.IsNullOrEmpty(k) && !string.IsNullOrWhiteSpace(k))
                    {
                        var clean = rgx.Replace(k, "").ToLower();

                        if (!search.Contains(clean))
                        {
                            continue;
                        }

                        match = true;
                        break;
                    }
                }
            }

            return(match);
        }
예제 #14
0
        public static Bitmap GetPoster(PlexObject stream, bool waitWindow = true)
        {
            if (waitWindow)
            {
                return((Bitmap)WaitWindow.WaitWindow.Show(GetPoster, @"Grabbing poster", stream));
            }

            var result = GetImageFromUrl(stream.StreamInformation.ContentThumbnailUri);

            if (result == Resources.unavailable)
            {
                return(result);
            }
            if (!ObjectProvider.Settings.Generic.AdultContentProtection)
            {
                return(result);
            }

            return(Methods.AdultKeywordCheck(stream) ? Pixelation.Pixelate(result, 64) : result);
        }
예제 #15
0
 private void NextTitle()
 {
     if (((StreamingContent.StreamIndex + 1) < TitlesTable.Rows.Count))
     {
         PlexMovie next = GetObjectFromIndex(StreamingContent.StreamIndex + 1);
         StreamingContent = next;
         string FormTitle = StreamingContent.StreamInformation.ContentTitle;
         this.Text = FormTitle;
         this.Refresh();
         //MessageBox.Show(StreamingContent.StreamIndex + "\n" + TitlesTable.Rows.Count);
     }
     else if ((StreamingContent.StreamIndex + 1) == TitlesTable.Rows.Count)
     {
         PlexMovie next = GetObjectFromIndex(0);
         StreamingContent = next;
         string FormTitle = StreamingContent.StreamInformation.ContentTitle;
         this.Text = FormTitle;
         this.Refresh();
         //MessageBox.Show(StreamingContent.StreamIndex + "\n" + TitlesTable.Rows.Count);
     }
 }
예제 #16
0
 private void PrevTitle()
 {
     if (StreamingContent.StreamIndex != 0)
     {
         PlexMovie next = GetObjectFromIndex(StreamingContent.StreamIndex - 1);
         StreamingContent = next;
         string FormTitle = StreamingContent.StreamInformation.ContentTitle;
         this.Text = FormTitle;
         this.Refresh();
         //MessageBox.Show(StreamingContent.StreamIndex + "\n" + TitlesTable.Rows.Count);
     }
     else
     {
         PlexMovie next = GetObjectFromIndex(TitlesTable.Rows.Count - 1);
         StreamingContent = next;
         string FormTitle = StreamingContent.StreamInformation.ContentTitle;
         this.Text = FormTitle;
         this.Refresh();
         //MessageBox.Show(StreamingContent.StreamIndex + "\n" + TitlesTable.Rows.Count);
     }
 }
예제 #17
0
        public static PlexObject MetadataFromFile(string fileName)
        {
            try
            {
                PlexObject subReq = null;

                XmlSerializer serializer = new XmlSerializer(typeof(PlexObject));

                StreamReader reader = new StreamReader(fileName);
                subReq = (PlexObject)serializer.Deserialize(reader);
                reader.Close();

                return(subReq);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred\n\n" + ex.ToString(), "Metadata Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Home.recordException(ex.Message, "XMLMetadataLoadError");
                return(new PlexObject());
            }
        }
예제 #18
0
        private void NextTitle()
        {
            //check if the table has been loaded correctly before trying
            //to get data from it.
            if (!TableManager.ActiveTableFilled)
            {
                return;
            }

            if (StreamingContent.StreamIndex + 1 < TableManager.ReturnCorrectTable().Rows.Count)
            {
                //fetch the correct content
                var next = GetObjectFromIndex(StreamingContent.StreamIndex + 1);
                StreamingContent = next;
                var formTitle = StreamingContent.StreamInformation.ContentTitle;

                //set the form title to the new content
                Text = formTitle;

                //reset and repaint the GUI
                Stop(true);
                Refresh();
            }
            else if (StreamingContent.StreamIndex + 1 == TableManager.ReturnCorrectTable().Rows.Count)
            {
                //fetch the correct content
                var next = GetObjectFromIndex(0);
                StreamingContent = next;

                var formTitle = StreamingContent.StreamInformation.ContentTitle;

                //set the form title to the new content
                Text = formTitle;

                //reset and repaint the GUI
                Stop(true);
                Refresh();
            }
        }
예제 #19
0
        public static XmlDocument ToXml(this PlexObject obj)
        {
            try
            {
                var xsSubmit    = new XmlSerializer(typeof(PlexObject));
                var xmlSettings = new XmlWriterSettings();
                var sww         = new StringWriter();
                xmlSettings.Indent             = true;
                xmlSettings.IndentChars        = "\t";
                xmlSettings.OmitXmlDeclaration = false;

                xsSubmit.Serialize(sww, obj);

                var doc = new XmlDocument();
                doc.LoadXml(sww.ToString());

                return(doc);
            }
            catch
            {
                return(null);
            }
        }
예제 #20
0
        public static void RunMetadataWindow(PlexObject metadata, bool appRun = false)
        {
            var form = new Metadata();

            if (metadata != null)
            {
                form.StreamingContent = metadata;

                if (appRun)
                {
                    Application.Run(form);
                }
                else
                {
                    form.ShowDialog();
                }
            }
            else
            {
                UIMessages.Error(@"Invalid PlexMovie Metadata File; the decoded data was null.",
                                 @"Validation Error");
            }
        }
        private System.IO.Stream InternalGetFile(int userid, string Id, HistoryInfo info)
        {
            int id;

            if (!int.TryParse(Id, out id))
            {
                return(new MemoryStream());
            }
            VideoLocalRepository repVids = new VideoLocalRepository();
            PlexObject           ret     = new PlexObject(PlexHelper.NewMediaContainer(MediaContainerTypes.File, info, true));
            VideoLocal           vi      = repVids.GetByID(id);

            if (vi == null)
            {
                return(new MemoryStream());
            }
            List <Video> dirs = new List <Video>();
            Video        v2   = new Video();

            PlexHelper.PopulateVideo(v2, vi, JMMType.File, userid);
            dirs.Add(v2, info);
            ret.MediaContainer.Childrens = dirs;
            return(ret.GetStream());
        }
예제 #22
0
 //just to make it easier :)
 private static string FormatFramerate(PlexObject streamingContent)
 {
     return(!string.Equals(streamingContent.StreamResolution.Framerate, "Unknown")
         ? ResolutionStandards.FullFpsSuffix(streamingContent.StreamResolution.Framerate)
         : "Unknown");
 }
예제 #23
0
 /// <summary>
 /// Try and launch the cast window with the specified content
 /// </summary>
 /// <param name="content">The PlexObject to cast</param>
 public static void TryCast(PlexObject content)
 => new Cast()
 {
     StreamingContent = content
 }.ShowDialog();
        private System.IO.Stream GetGroupsFromFilter(int userid, string GroupFilterId, HistoryInfo info)
        {
            PlexObject ret = new PlexObject(PlexHelper.NewMediaContainer(MediaContainerTypes.Show, info, false));

            if (!ret.Init())
            {
                return(new MemoryStream());
            }

            //List<Joint> retGroups = new List<Joint>();
            List <Video> retGroups = new List <Video>();

            try
            {
                int groupFilterID;
                int.TryParse(GroupFilterId, out groupFilterID);
                using (var session = JMMService.SessionFactory.OpenSession())
                {
                    if (groupFilterID == -1)
                    {
                        return(new MemoryStream());
                    }
                    DateTime start = DateTime.Now;
                    GroupFilterRepository repGF = new GroupFilterRepository();

                    GroupFilter gf;

                    if (groupFilterID == -999)
                    {
                        // all groups
                        gf = new GroupFilter();
                        gf.GroupFilterName = "All";
                    }
                    else
                    {
                        gf = repGF.GetByID(session, groupFilterID);
                        if (gf == null)
                        {
                            return(new MemoryStream());
                        }
                    }
                    //Contract_GroupFilterExtended contract = gf.ToContractExtended(user);

                    AnimeGroupRepository repGroups = new AnimeGroupRepository();
                    List <AnimeGroup>    allGrps   = repGroups.GetAll(session);



                    TimeSpan ts  = DateTime.Now - start;
                    string   msg = string.Format("Got groups for filter DB: {0} - {1} in {2} ms", gf.GroupFilterName,
                                                 allGrps.Count, ts.TotalMilliseconds);
                    logger.Info(msg);
                    start = DateTime.Now;



                    if ((StatsCache.Instance.StatUserGroupFilter.ContainsKey(userid)) &&
                        (StatsCache.Instance.StatUserGroupFilter[userid].ContainsKey(gf.GroupFilterID)))
                    {
                        HashSet <int> groups = StatsCache.Instance.StatUserGroupFilter[userid][gf.GroupFilterID];

                        foreach (AnimeGroup grp in allGrps)
                        {
                            if (groups.Contains(grp.AnimeGroupID))
                            {
                                Video v = StatsCache.Instance.StatPlexGroupsCache[userid][grp.AnimeGroupID];
                                if (v != null)
                                {
                                    v = v.Clone();

                                    retGroups.Add(v, info);
                                }
                            }
                        }
                    }
                    ts  = DateTime.Now - start;
                    msg = string.Format("Got groups for filter EVAL: {0} - {1} in {2} ms", gf.GroupFilterName,
                                        retGroups.Count, ts.TotalMilliseconds);
                    logger.Info(msg);
                    if ((groupFilterID == -999) || (gf.SortCriteriaList.Count == 0))
                    {
                        ret.Childrens = PlexHelper.ConvertToDirectoryIfNotUnique(retGroups.OrderBy(a => a.Group.SortName).ToList());
                        return(ret.GetStream());
                    }
                    List <Contract_AnimeGroup>         grps         = retGroups.Select(a => a.Group).ToList();
                    List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>();
                    foreach (GroupFilterSortingCriteria g in gf.SortCriteriaList)
                    {
                        sortCriteria.Add(GroupFilterHelper.GetSortDescription(g.SortType, g.SortDirection));
                    }
                    grps = Sorting.MultiSort(grps, sortCriteria);
                    List <Video> joints2 = new List <Video>();
                    foreach (Contract_AnimeGroup gr in grps)
                    {
                        foreach (Video j in retGroups)
                        {
                            if (j.Group == gr)
                            {
                                joints2.Add(j);
                                retGroups.Remove(j);
                                break;
                            }
                        }
                    }
                    ret.Childrens = PlexHelper.ConvertToDirectoryIfNotUnique(joints2);
                    ts            = DateTime.Now - start;
                    msg           = string.Format("Got groups final: {0} - {1} in {2} ms", gf.GroupFilterName,
                                                  retGroups.Count, ts.TotalMilliseconds);
                    logger.Info(msg);
                    return(ret.GetStream());
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            return(new MemoryStream());
        }
예제 #25
0
        public static void MetadataToFile(string fileName, PlexObject contentToExport, Bitmap poster = null, bool silent = false)
        {
            try
            {
                //try and obtain a poster if one wasn't provided
                var p = poster ?? ImageHandler.GetPoster(contentToExport);

                //create each new PXZ record in memory
                var rawMetadata = new PxzRecord(contentToExport.RawMetadata, @"raw");
                var objMetadata = new PxzRecord(contentToExport.ToXml(), @"obj");
                var ptrMetadata = new PxzRecord(p, @"poster");

                //the records to save to the PXZ file are contained in a list
                var data = new List <PxzRecord>
                {
                    rawMetadata,
                    objMetadata,
                    ptrMetadata
                };

                //export the actor images (if any)
                if (contentToExport.Actors != null)
                {
                    if (contentToExport.Actors.Count > 0)
                    {
                        //loop through each actor and attempt an image download
                        foreach (var a in contentToExport.Actors)
                        {
                            //download
                            var image = ImageHandler.GetImageFromUrl(a.ThumbnailUri);

                            //verify
                            if (image != Resources.unavailable)
                            {
                                //create a new record for the image
                                var record = new PxzRecord(image, $"actor_{MD5Helper.CalculateMd5Hash(a.ThumbnailUri)}");

                                //add it to the collection
                                data.Add(record);
                            }
                        }
                    }
                }

                //embedded in PXZ indexing information
                var plexdlVersion = Assembly.GetEntryAssembly()?.GetName().Version;

                //initialise the PXZ file and flush it to disk
                var pxz = new PxzFile(data, plexdlVersion, BuildState.State);
                pxz.Save(fileName);

                //show a message indicating success if allowed
                if (!silent)
                {
                    UIMessages.Info(@"Successfully exported metadata!");
                }
            }
            catch (Exception ex)
            {
                if (!silent)
                {
                    UIMessages.Error("An error occurred\n\n" + ex, @"Metadata Export Error");
                }
                LoggingHelpers.RecordException(ex.Message, "XmlMetadataSaveError");
            }
        }
예제 #26
0
        public static void LaunchVlc(PlexObject stream)
        {
            try
            {
                if (!Methods.StreamAdultContentCheck(stream))
                {
                    return;
                }

                var p = new Process();
                var c = new StringVariableController();

                var vlc = ObjectProvider.Settings.Player.VlcMediaPlayerPath;
                var arg = ObjectProvider.Settings.Player.VlcMediaPlayerArgs;

                if (VlcInstalled())
                {
                    c.Input = arg;

                    c.Variables = c.BuildFromDlInfo(stream.StreamInformation);
                    arg         = c.YieldString();

                    p.StartInfo.FileName  = vlc;
                    p.StartInfo.Arguments = arg;
                    p.Start();
                    LoggingHelpers.RecordGeneralEntry("Started streaming " + stream.StreamInformation.ContentTitle +
                                                      " (VLC)");
                }
                else
                {
                    UIMessages.Error(@"PlexDL could not find VLC Media Player. Please locate VLC and then try again.");

                    var ofd = new OpenFileDialog
                    {
                        Filter      = @"VLC Executable|vlc.exe",
                        Title       = @"Locate VLC Media Player",
                        Multiselect = false
                    };

                    if (ofd.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    var fileName = ofd.FileName;
                    var baseName = Path.GetFileName(fileName).ToLower();

                    if (baseName == "vlc.exe")
                    {
                        //apply the newly-located vlc.exe to global settings for persistence
                        ObjectProvider.Settings.Player.VlcMediaPlayerPath = fileName;

                        //finally, launch VLC itself.
                        LaunchVlc(stream);
                    }
                    else
                    {
                        UIMessages.Error(@"Invalid VLC Media Player executable name");
                    }
                }
            }
            catch (Exception ex)
            {
                UIMessages.Error("Error occurred whilst trying to launch VLC\n\n" + ex, @"Launch Error");
                LoggingHelpers.RecordException(ex.Message, "VLCLaunchError");
            }
        }
예제 #27
0
        public static QueueResult NewQueue(PlexObject content, MyPlex.Server server)
        {
            var q = new QueueResult();

            try
            {
                var          ip       = server.address;
                var          port     = server.port;
                const string protocol = @"http";

                //POST data values

                //Constants
                const string type       = @"video";
                const int    shuffle    = 0;
                const int    repeat     = 0;
                const int    continuous = 0;
                const int    own        = 1;

                //Dynamic
                var uri = $"server://{server.machineIdentifier}/com.plexapp.plugins.library{content.ApiUri}";

                //assemble URLs
                var baseUri  = $"{protocol}://{ip}:{port}";
                var resource = @"playQueues";

                using (var httpClient = new HttpClient())
                {
                    using (var request = new HttpRequestMessage(new HttpMethod("POST"),
                                                                $"{baseUri}/{resource}?type={type}&shuffle={shuffle}" +
                                                                $"&repeat={repeat}&continuous={continuous}" +
                                                                $"&own={own}&uri={uri}"))
                    {
                        request.Headers.TryAddWithoutValidation("X-Plex-Client-Identifier",
                                                                "AB6CCCC7-5CF5-4523-826A-B969E0FFD8A0");
                        request.Headers.TryAddWithoutValidation("X-Plex-Token", "PzhwzBRtb1jQqfRypxDo");

                        var response = httpClient.SendAsync(request).Result;

                        if (response.IsSuccessStatusCode)
                        {
                            if (response.Content != null)
                            {
                                var d = response.Content.ReadAsStringAsync().Result
                                        .ParseXml <MediaContainer>();

                                q.QueueId      = d.playQueueID;
                                q.QueueSuccess = true;
                                q.QueueObject  = d;
                                q.QueueUri     = $"/playQueues/{d.playQueueID}?own=1&window=200";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, @"QueueAddError");
            }

            return(q);
        }
예제 #28
0
 /// <summary>
 /// Utilise the currently connected server to prefill content data information
 /// </summary>
 /// <param name="content"></param>
 /// <returns></returns>
 public static MediaData DataFromContent(PlexObject content)
 => DataFromContent(content, ObjectProvider.Svr);
예제 #29
0
        public static async void LoadPlexMedia(this PlexChannel channel, ChromeCastClient client, PlexObject content)
        {
            var mediaObject = PlexMediaData.DataFromContent(content);
            var req         = new LoadRequest(client.CurrentApplicationSessionId, mediaObject, true, 0, mediaObject.CustomData);

            var reqJson = req.ToJson();
            await channel.Write(MessageFactory.Load(client.CurrentApplicationTransportId, reqJson));
        }
예제 #30
0
 /// <summary>
 /// Show a media link based on a PlexObject
 /// </summary>
 /// <param name="media">The PlexObject which contains the link</param>
 /// <param name="viewMode">View mode will toggle the 'download' GET parameter</param>
 public static void ShowLinkViewer(PlexObject media, bool viewMode = true)
 => ShowLinkViewer(viewMode
         ? media.StreamInformation.Links.View
         : media.StreamInformation.Links.Download);