Skip to content

Commit

Permalink
* Refactored Plex code.
Browse files Browse the repository at this point in the history
* Fixed almost all glitches on Plex clients. (May increse the startup time of JMMServer the first time)
* Added experimental UPnP to the FileServer. Experimental UPnP requires changes in the plex plugin, but, may fix (Remote Clients may be unable to play video, if the video do not requires transcoding. PlexPlugin Issue #9) if the router supports Hairpin NAT.
* Fixed subtitle/audiostreams languages name in plex (somehow visual studio dosn't like kana strings).
* Fixed Plex Plugin does not display info text about the episode correctly. PlexPlugin Issue #8
* May fix Plex for XBMC has thumbnails broken. PlexPlugin #2. (Require testing).
  • Loading branch information
maxpiva committed Feb 8, 2015
1 parent 6572b13 commit 6c5b53f
Show file tree
Hide file tree
Showing 17 changed files with 715 additions and 1,223 deletions.
6 changes: 4 additions & 2 deletions JMMContracts/Contract_AnimeSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class Contract_AnimeSeries
public Contract_CrossRef_AniDB_Other CrossRefAniDBMovieDB { get; set; }
public List<Contract_CrossRef_AniDB_MAL> CrossRefAniDBMAL { get; set; }
public List<Contract_TvDB_Series> TvDB_Series { get; set; }
public Contract_AnimeGroup TopLevelGroup { get; set; }
}
public Contract_MovieDB_Movie MovieDB_Movie { get; set; }
public Contract_AnimeGroup TopLevelGroup { get; set; }

}
}
112 changes: 105 additions & 7 deletions JMMContracts/PlexContracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using JMMContracts.PlexContracts;

namespace JMMContracts.PlexContracts
{
[XmlType("MediaContainer")]
[Serializable]
public class MediaContainer
{
[XmlElement("Video")]
public List<Video> Videos { get; set; }

[XmlElement("Directory")]
public List<Video> Directories { get; set; }
[XmlElement(typeof(Video), ElementName = "Video")]
[XmlElement(typeof(Directory), ElementName = "Directory")]
public List<Video> Childrens { get; set; }

[XmlAttribute("viewGroup")]
public string ViewGroup { get; set; }
Expand Down Expand Up @@ -60,9 +60,20 @@ public class MediaContainer
[XmlAttribute("offset")]
public string Offset { get; set; }

[XmlAttribute("librarySectionUUID")]
public string LibrarySectionUUID { get; set; }

[XmlAttribute("librarySectionTitle")]
public string LibrarySectionTitle { get; set; }

[XmlAttribute("librarySectionID")]
public string LibrarySectionID { get; set; }

}


[XmlRoot(ElementName = "Directory")]
public class Directory : Video { }

[XmlType("Video")]
[Serializable]
public class Video
Expand All @@ -79,6 +90,12 @@ public class Video
[XmlElement("Role")]
public List<Tag> Roles { get; set; }

[XmlElement("Extras")]
public Extras Extras { get; set; }

[XmlElement("Related")]
public List<Hub> Related { get; set; }

[XmlElement("Tag")]
public List<Tag> Tags { get; set; }

Expand All @@ -93,13 +110,36 @@ public class Video
[XmlAttribute("thumb")]
public string Thumb { get; set; }

[XmlAttribute("parentThumb")]
public string ParentThumb { get; set; }


[XmlAttribute("grandparentThumb")]
public string GrandparentThumb { get; set; }

[XmlAttribute("ratingKey")]
public string RatingKey { get; set; }

[XmlAttribute("parentRatingkey")]
public string ParentRatingKey { get; set; }

[XmlAttribute("grandparentRatingKey")]
public string GrandparentRatingKey { get; set; }

[XmlAttribute("key")]
public string Key { get; set; }

[XmlAttribute("parentKey")]
public string ParentKey { get; set; }
[XmlAttribute("grandparentKey")]
public string GrandparentKey { get; set; }

[XmlAttribute("index")]
public string Index { get; set; }

[XmlAttribute("parentIndex")]
public string ParentIndex { get; set; }

[XmlAttribute("guid")]
public string Guid { get; set; }

Expand All @@ -109,6 +149,13 @@ public class Video
[XmlAttribute("title")]
public string Title { get; set; }

[XmlAttribute("parentTitle")]
public string ParentTitle { get; set; }

[XmlAttribute("grandparentTitle")]
public string GrandparentTitle { get; set; }


[XmlAttribute("summary")]
public string Summary { get; set; }

Expand Down Expand Up @@ -155,6 +202,24 @@ public class Video
public string ViewCount { get; set; }
[XmlAttribute("viewOffset")]
public string ViewOffset { get; set; }

[XmlAttribute("primaryExtraKey")]
public string PrimaryExtraKey { get; set; }

[XmlAttribute("chapterSource")]
public string ChapterSource { get; set; }

[XmlAttribute("tagline")]
public string Tagline { get; set; }

[XmlAttribute("contentRating")]
public string ContentRating { get; set; }

[XmlAttribute("studio")]
public string Studio { get; set; }

[XmlAttribute("extraType")]
public string ExtraType { get; set; }
}

[Serializable]
Expand All @@ -169,8 +234,6 @@ public class Tag
public class Media
{



[XmlElement("Part")]
public List<Part> Parts { get; set; }

Expand Down Expand Up @@ -400,6 +463,41 @@ public class PlexContract_Users
[XmlElement("User")]
public List<PlexContract_User> Users { get; set; }
}

[XmlType("Extras")]
public class Extras
{
[XmlAttribute("size")]
public string Size { get; set; }

[XmlElement("Video")]
public List<Video> Videos { get; set; }
}

[XmlType("Hub")]
public class Hub
{
[XmlAttribute("key")]
public string Key { get; set; }

[XmlAttribute("type")]
public string Type { get; set; }

[XmlAttribute("hubIdentifier")]
public string HubIdentifier { get; set; }

[XmlAttribute("size")]
public string Size { get; set; }

[XmlAttribute("title")]
public string Title { get; set; }


[XmlAttribute("more")]
public string More { get; set; }


}
public enum JMMType
{
GroupFilter,
Expand Down
8 changes: 4 additions & 4 deletions JMMFileHelper/Hasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace JMMFileHelper
{
public class Hasher
{
private static Logger logger = LogManager.GetCurrentClassLogger();
public delegate int OnHashProgress([MarshalAs(UnmanagedType.LPStr)]string strFileName, int nProgressPct);
public static Logger logger = LogManager.GetCurrentClassLogger();
public delegate int OnHashProgress([MarshalAs(UnmanagedType.LPTStr)]string strFileName, int nProgressPct);

[System.Flags]
internal enum LoadLibraryFlags : uint
Expand Down Expand Up @@ -62,9 +62,9 @@ static Hasher()
}

#region DLL functions
[DllImport("hasher.dll", EntryPoint = "CalculateHashes_AsyncIO", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
[DllImport("hasher.dll", EntryPoint = "CalculateHashes_AsyncIO", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern int CalculateHashes_callback_dll(
[MarshalAs(UnmanagedType.LPStr)] string szFileName,
[MarshalAs(UnmanagedType.LPTStr)] string szFileName,
[MarshalAs(UnmanagedType.LPArray)] byte[] hash,
[MarshalAs(UnmanagedType.FunctionPtr)] OnHashProgress lpHashProgressFunc,
[MarshalAs(UnmanagedType.Bool)] bool getCRC32,
Expand Down
15 changes: 9 additions & 6 deletions JMMFileHelper/MediaInfoReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using JMMContracts.PlexContracts;
using NLog;
using JMMContracts;

namespace JMMFileHelper
{
public class MediaInfoReader
{
private static Logger logger = LogManager.GetCurrentClassLogger();
public class MediaInfoReader
{
private static Logger logger = LogManager.GetCurrentClassLogger();

private static string XmlSerializeToString<T>(T objectInstance)
{
Expand All @@ -28,9 +29,10 @@ private static string XmlSerializeToString<T>(T objectInstance)
return sb.ToString();
}

public static bool ReadMediaInfo(string fileNameFull, bool forceRefresh, ref MediaInfoResult info)
{
try
public static bool ReadMediaInfo(string fileNameFull, bool forceRefresh, ref MediaInfoResult info)

{
try
{

if (!forceRefresh)
Expand All @@ -41,6 +43,7 @@ public static bool ReadMediaInfo(string fileNameFull, bool forceRefresh, ref Med
Media m = PlexMediaInfo.MediaConvert.Convert(fileNameFull);
if (m != null)
{

string xml = XmlSerializeToString(m);
if (!string.IsNullOrEmpty(m.Width) && !string.IsNullOrEmpty(m.Height))
info.VideoResolution = m.Width + "x" + m.Height;
Expand Down
Loading

0 comments on commit 6c5b53f

Please sign in to comment.