Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
skipperbent committed Nov 25, 2018
1 parent cfec55c commit 3c0b369
Show file tree
Hide file tree
Showing 35 changed files with 75 additions and 61 deletions.
Binary file modified .vs/Pecee.Emby.Plugin.Vod/v15/.suo
Binary file not shown.
Binary file modified .vs/Pecee.Emby.Plugin.Vod/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/Pecee.Emby.Plugin.Vod/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified .vs/Pecee.Emby.Plugin.Vod/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
26 changes: 10 additions & 16 deletions Project/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Task<DynamicImageResponse> GetChannelImage(ImageType type, CancellationTo
}
catch (Exception e)
{
Plugin.Instance.Logger.ErrorException("VOD: Error getting channel image", e);
Plugin.Instance.Logger.ErrorException("[VOD] Error: " + e.Message, e);
}

return null;
Expand All @@ -107,7 +107,7 @@ public IEnumerable<ImageType> GetSupportedChannelImages()

public Task<ChannelItemResult> GetChannelPlaylists(CancellationToken cancellationToken)
{
Plugin.Instance.Logger.Info("VOD: Get channel playlists");
Plugin.Instance.Logger.Debug("[VOD] Get channel playlists");
var items = Plugin.Instance.Configuration.Playlists.Select(p => new ChannelItemInfo()
{
Id = ChannelFolder.GetUrl(ChannelFolderType.Playlist, p.IdentifierId.ToString()),
Expand All @@ -118,7 +118,7 @@ public Task<ChannelItemResult> GetChannelPlaylists(CancellationToken cancellatio
Name = p.Name,
}).OrderBy(i => i.Name).ToList();

_logger.Info("VOD: found {0} items", items.Count);
_logger.Debug("[VOD] found {0} items", items.Count);

return Task.FromResult(new ChannelItemResult()
{
Expand All @@ -130,32 +130,32 @@ public Task<ChannelItemResult> GetChannelPlaylists(CancellationToken cancellatio
public async Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken)
{

Plugin.Instance.Logger.Info("VOD: Get channel items");
Plugin.Instance.Logger.Debug("[VOD] Get channel items");

if (string.IsNullOrWhiteSpace(query.FolderId))
{
_logger.Info("VOD: Channel items default");
_logger.Debug("[VOD] Channel items default");
return await GetAllMedia(query, cancellationToken).ConfigureAwait(false);
//return await GetChannelPlaylists(cancellationToken).ConfigureAwait(false);
}


var folder = ChannelFolder.Parse(query.FolderId);

Plugin.Instance.Logger.Debug("VOD: Render channel folder id: {0}", query.FolderId);
Plugin.Instance.Logger.Debug("[VOD] Render channel folder id: {0}", query.FolderId);

switch (folder.Type)
{
default:
case ChannelFolderType.Playlist:
{
Plugin.Instance.Logger.Info("VOD: Get channel items playlist for id: {0} - {1}", folder.Id, folder.Type.ToString());
Plugin.Instance.Logger.Debug("[VOD] Get channel items playlist for id: {0} - {1}", folder.Id, folder.Type.ToString());
var playlist = _libraryManager.GetUserRootFolder().GetRecursiveChildren().OfType<VodPlaylist>()
.FirstOrDefault(p => p.IdentifierId.ToString() == folder.Id.ToString());

if (playlist != null)
{
Plugin.Instance.Logger.Info("VOD: Found channel playlist: {0}", playlist.Name);
Plugin.Instance.Logger.Debug("[VOD] Found channel playlist: {0}", playlist.Name);
return await new Task<ChannelItemResult>(() => GetPlaylistItems(playlist), cancellationToken).ConfigureAwait(false);
}

Expand All @@ -173,7 +173,7 @@ public async Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery qu
public ChannelItemResult GetPlaylistItems(VodPlaylist playlist)
{

Plugin.Instance.Logger.Info("VOD: Get playlist items");
Plugin.Instance.Logger.Debug("[VOD] Get playlist items");
var mediaItems = playlist.GetRecursiveChildren().OfType<VodMovie>();

var items = (from media in mediaItems
Expand Down Expand Up @@ -230,16 +230,10 @@ public Task<ChannelItemResult> GetAllMedia(InternalChannelItemQuery query, Cance
return Task.FromResult(result);
}

/*public Task LoadRegistrationInfoAsync()
{
Plugin.Instance.Registration = await PluginSecurityManager.GetRegistrationStatus(PluginConfiguration.Name).ConfigureAwait(false);
Plugin.Logger.Debug("PodCasts Registration Status - Registered: {0} In trial: {2} Expiration Date: {1} Is Valid: {3}", Plugin.Instance.Registration.IsRegistered, Plugin.Instance.Registration.ExpirationDate, Plugin.Instance.Registration.TrialVersion, Plugin.Instance.Registration.IsValid);
}*/

public Task<IEnumerable<ChannelItemInfo>> Search(ChannelSearchInfo searchInfo, CancellationToken cancellationToken)
{

Plugin.Instance.Logger.Info("VOD: Search");
Plugin.Instance.Logger.Debug("[VOD] Search");

return new Task<IEnumerable<ChannelItemInfo>>(delegate
{
Expand Down
19 changes: 10 additions & 9 deletions Project/Configuration/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ <h3>Add new Playlist</h3>
</label>
<input id="url" type="url" required class="emby-input">
</div>
<div class="checkboxContainer">
<label class="inputLabel inputLabel-float inputLabelUnfocused" for="create_collection">
Create local collection
<input is="emby-checkbox" id="create_collection" type="checkbox" value="1" class="emby-input">
<span>Create visible collection outside the channel</span>
</label>
</div>
<!--<div class="checkboxContainer">
<label class="inputLabel inputLabel-float inputLabelUnfocused" for="create_collection">
Create local collection
<input is="emby-checkbox" id="create_collection" type="checkbox" value="1" class="emby-input">
<span>Create visible collection outside the channel</span>
</label>
</div>-->
<div class="checkboxContainer">
<label class="inputLabel inputLabel-float inputLabelUnfocused" for="strict_sync">
Strict Sync
<input is="emby-checkbox" id="strict_sync" type="checkbox" value="1" class="emby-input">
<input is="emby-checkbox" id="strict_sync" type="checkbox" checked="checked" value="1" class="emby-input">
<span>When items are deleted remotely, local items will also be deleted.</span>
</label>
</div>
Expand Down Expand Up @@ -123,6 +123,7 @@ <h3>Add new Playlist</h3>
var page = $(link).parents('.page')[0];

VodConfigurationPage.save();
VodConfigurationPage.triggerSync();
VodConfigurationPage.populatePlaylists(page);
}
});
Expand Down
2 changes: 1 addition & 1 deletion Project/Entities/PlaylistConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public VodPlaylist ToPlaylist()
PlaylistUrl = this.Url,
//CollectionType = playlistConf.CollectionType,
IdentifierId = this.IdentifierId,
IsHidden = !CreateLocalCollection
IsHidden = !CreateLocalCollection,
};
}
}
Expand Down
5 changes: 2 additions & 3 deletions Project/Models/VodPlaylist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class VodPlaylist : MediaBrowser.Controller.Entities.Folder, IColl

//private String _collectionType;

public override bool IsDisplayedAsFolder => false;
public override bool IsDisplayedAsFolder => true;

public PlaylistConfig Config { get; set; }

Expand Down Expand Up @@ -66,8 +66,7 @@ public VodPlaylist()
IdentifierId = Guid.NewGuid();
SourceType = SourceType.Library;
IsVirtualItem = false;

//IsHidden = true;
IsHidden = true;
}

public bool Merge(VodPlaylist remote)
Expand Down
16 changes: 8 additions & 8 deletions Project/Parser/M3UParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public Dictionary<string, string> ParseAttributes(string line)
var attributeMatches = _regexPattern.Matches(line);
if (attributeMatches.Count == 0)
{
_logger.Debug("No attributes found", attributeMatches.Count);
_logger.Debug("[VOD] No attributes found", attributeMatches.Count);
return attributes;
}

_logger.Debug("Found {0} attributes", attributeMatches.Count);
_logger.Debug("[VOD] Found {0} attributes", attributeMatches.Count);

foreach (Match attribute in attributeMatches)
{
Expand All @@ -57,7 +57,7 @@ public Dictionary<string, string> ParseAttributes(string line)
continue;
}

_logger.Debug("Key: {0} - Value: {1}", key, value);
_logger.Debug("[VOD] Key: {0} - Value: {1}", key, value);
attributes.Add(key, value);
}

Expand All @@ -68,7 +68,7 @@ public async Task<List<Media>> GetMediaItems(VodPlaylist playlist, CancellationT
{
var items = new List<Media>();

_logger.Debug("{0}: Starting to parse: {1}", playlist.Name, playlist.PlaylistUrl);
_logger.Debug("[VOD] {0}: Starting to parse: {1}", playlist.Name, playlist.PlaylistUrl);

using (Stream stream = await _httpClient.Get(new HttpRequestOptions()
{
Expand All @@ -84,11 +84,11 @@ public async Task<List<Media>> GetMediaItems(VodPlaylist playlist, CancellationT

if (line.IndexOf("#EXTINF", StringComparison.CurrentCulture) != 0)
{
_logger.Debug("{0}: Non-valid line, skipping", playlist.Name);
_logger.Debug("[VOD] {0}: Non-valid line, skipping", playlist.Name);
continue;
}

_logger.Debug("Found line with #EXTINF meta information");
_logger.Debug("[VOD] Found line with #EXTINF meta information");

var attributes = ParseAttributes(line);

Expand All @@ -103,12 +103,12 @@ public async Task<List<Media>> GetMediaItems(VodPlaylist playlist, CancellationT
// Fetch logo
if (attributes.ContainsKey("tvg-logo"))
{
_logger.Debug("Found tvg-logo: {0}", attributes["tvg-logo"]);
_logger.Debug("[VOD] Found tvg-logo: {0}", attributes["tvg-logo"]);
Uri.TryCreate(attributes["tvg-logo"], UriKind.Absolute, out imgUri);
}

var imageUrl = (imgUri != null) ? imgUri.ToString() : null;
_logger.Debug("Adding: {0}, stream playlistUrl: {0}, image: {0}", attributes["tvg-name"], streamUrl, imageUrl);
_logger.Debug("[VOD] Adding: {0}, stream playlistUrl: {0}, image: {0}", attributes["tvg-name"], streamUrl, imageUrl);

var media = new Media()
{
Expand Down
6 changes: 3 additions & 3 deletions Project/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override void OnUninstalling()
{

// Cleanup
Logger.Info("Start uninstall cleanup");
Logger.Debug("[VOD] Start uninstall cleanup");

var types = new []
{
Expand All @@ -63,7 +63,7 @@ public override void OnUninstalling()

foreach (var playlist in LibraryManager.GetItemList(new InternalItemsQuery(), false).Where(i => types.Contains(i.GetType())).ToList())
{
Logger.Info("Removing VOD playlist: {0}", playlist.Name);
Logger.Debug("[VOD] Removing playlist: {0}", playlist.Name);

LibraryManager.DeleteItem(playlist, new DeleteOptions()
{
Expand All @@ -72,7 +72,7 @@ public override void OnUninstalling()
}, true);
}

Logger.Info("Finished uninstall cleanup");
Logger.Debug("[VOD] Finished uninstall cleanup");

base.OnUninstalling();
}
Expand Down
1 change: 0 additions & 1 deletion Project/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
<Content Include="Parser\obj\Debug\Pecee.Plugin.Emby.Vod.pdb" />
</ItemGroup>
<ItemGroup>
<Folder Include="obj\" />
<Folder Include="Parser\Api\" />
<Folder Include="Parser\Configuration\" />
<Folder Include="Parser\dashboard-ui\" />
Expand Down
40 changes: 21 additions & 19 deletions Project/Scheduler/PlaylistLibrarySync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PlaylistLibrarySync : IScheduledTask
private readonly IProviderManager _providerManager;
private readonly M3UParser _m3UParser;

public string Name => "Video on Demand Playlist";
public string Name => "Video on Demand Playlist Sync";

public string Key => "VodPlaylistLibrarySync";

Expand All @@ -46,27 +46,28 @@ M3UParser m3UParser

public async Task Cleanup(PlaylistConfig[] playlists, CancellationToken cancellationToken)
{
_logger.Debug("Cleaning up old and removed items");
_logger.Info("[VOD] Cleaning up old and removed items");

var deleteItems = _libraryManager.GetUserRootFolder()
.RecursiveChildren.OfType<VodPlaylist>()
.Where(p => p.Id == Guid.Empty || p.IdentifierId == Guid.Empty ||
(playlists.Length > 0 && playlists.FirstOrDefault(p1 => p1.IdentifierId == p.IdentifierId) == null))
(playlists.Length > 0 && playlists.FirstOrDefault(p1 => p1.IdentifierId == p.IdentifierId) == null) ||
playlists.Length == 0)
.Cast<BaseItem>().ToList();

_logger.Info("Found {0} playlists to remove", deleteItems.Count);
_logger.Info("[VOD] Found {0} playlists to remove", deleteItems.Count);

var mediaItems = _libraryManager.GetUserRootFolder()
.RecursiveChildren.OfType<VodMovie>()
.Where(p1 => p1.Id == Guid.Empty || p1.IdentifierId == Guid.Empty || playlists.FirstOrDefault(p2 => p2.IdentifierId == p1.ParentId) != null).Cast<BaseItem>().ToList();
.Where(p1 => p1.Id == Guid.Empty || p1.IdentifierId == Guid.Empty || playlists.FirstOrDefault(p2 => p2.IdentifierId == p1.ParentId) != null || playlists.Length == 0).Cast<BaseItem>().ToList();

deleteItems.AddRange(mediaItems);

_logger.Info("Found {0} mediaItems to remove", mediaItems.Count);
_logger.Info("[VOD] Found {0} items to remove", mediaItems.Count);

foreach (BaseItem item in deleteItems)
{
_logger.Debug("Removing dead item: {0}, id: {1}, parentId: {2}", item.Name, item.Id, item.ParentId);
_logger.Debug("[VOD] Removing item: {0}, id: {1}, parentId: {2}", item.Name, item.Id, item.ParentId);
_libraryManager.DeleteItem(item, new DeleteOptions()
{
DeleteFileLocation = true
Expand All @@ -83,11 +84,11 @@ public async Task Execute(CancellationToken cancellationToken, IProgress<double>
// No point going further if we don't have users.
if (playlists.Length == 0)
{
_logger.Info("No internal playlists added");
_logger.Info("[VOD] No internal playlists added");
return;
}

_logger.Info("Library sync started");
_logger.Info("[VOD] Library sync starting");

var existingPlaylists =
_libraryManager.GetUserRootFolder()
Expand All @@ -106,13 +107,13 @@ public async Task Execute(CancellationToken cancellationToken, IProgress<double>
if (existingPlaylist != null)
{
// UPDATE
_logger.Debug("{0}: playlist with id {1} and identifier {2} found, updating...", existingPlaylist.Name, existingPlaylist.Id, existingPlaylist.IdentifierId);
_logger.Debug("[VOD] {0}: playlist with id {1} and identifier {2} found, updating...", existingPlaylist.Name, existingPlaylist.Id, existingPlaylist.IdentifierId);
existingPlaylist.Merge(existingPlaylist);
}
else
{
// CREATE
_logger.Debug("{0}: playlist with identifier {1} not found, creating...", playlist.Name, playlist.IdentifierId);
_logger.Debug("[VOD] {0}: playlist with identifier {1} not found, creating...", playlist.Name, playlist.IdentifierId);
playlist.Id = _libraryManager.GetNewItemId(playlist.IdentifierId.ToString(), typeof(VodPlaylist));
_libraryManager.GetUserRootFolder().AddChild(playlist, cancellationToken);
}
Expand All @@ -133,7 +134,7 @@ public async Task Execute(CancellationToken cancellationToken, IProgress<double>

private async Task SyncMedia(VodPlaylist playlist, IProgress<double> progress, CancellationToken cancellationToken)
{
_logger.Info("{0}: parsing remote playlist: {1}", playlist.Name, playlist.PlaylistUrl);
_logger.Info("[VOD] {0}: parsing remote playlist: {1}", playlist.Name, playlist.PlaylistUrl);

List<Media> mediaItems = await _m3UParser.GetMediaItems(playlist, cancellationToken);

Expand Down Expand Up @@ -173,14 +174,14 @@ private async Task SyncMedia(VodPlaylist playlist, IProgress<double> progress, C
if (existingMediaItem != null)
{
// UPDATE
_logger.Debug("{0}: found item with id {1} and identifier {2}, updating...", playlist.Name, existingMediaItem.Id, existingMediaItem.IdentifierId);
_logger.Debug("[VOD] {0}: found item with id {1} and identifier {2}, updating...", playlist.Name, existingMediaItem.Id, existingMediaItem.IdentifierId);
await existingMediaItem.Merge(vodItem);
await RefreshMetaData(vodItem, cancellationToken).ConfigureAwait(false);
}
else
{
// CREATE
_logger.Debug("{0}: media {1} with identifier {2} not found, adding...", playlist.Name, vodItem.Name, vodItem.IdentifierId);
_logger.Debug("[VOD] {0}: media {1} with identifier {2} not found, adding...", playlist.Name, vodItem.Name, vodItem.IdentifierId);
vodItem.Id = _libraryManager.GetNewItemId(vodItem.IdentifierId.ToString(), typeof(VodMovie));
playlist.AddChild(vodItem, cancellationToken);

Expand All @@ -190,8 +191,9 @@ private async Task SyncMedia(VodPlaylist playlist, IProgress<double> progress, C
}
catch (Exception e)
{
_logger.ErrorException(e.Message, e);
}
_logger.ErrorException("[VOD] Error: " + e.Message, e);

}

i++;
}
Expand All @@ -201,7 +203,7 @@ private async Task SyncMedia(VodPlaylist playlist, IProgress<double> progress, C

private async Task<BaseItem> RefreshMetaData(BaseItem item, CancellationToken cancellationToken)
{
_logger.Info("{0}: Refreshing meta-data", item.Name);
_logger.Info("[VOD] {0}: Refreshing meta-data", item.Name);

// TODO: refresh meta-data for multiple content-types

Expand All @@ -219,11 +221,11 @@ private async Task<BaseItem> RefreshMetaData(BaseItem item, CancellationToken ca

if (metaResult == null)
{
_logger.Debug("{0}: Meta-data not found", item.Name);
_logger.Debug("[VOD] {0}: Meta-data not found", item.Name);
return item;
}

_logger.Debug("{0}: Found meta-data", item.Name);
_logger.Debug("[VOD] {0}: Found meta-data", item.Name);

item.Name = metaResult.Name;
item.Overview = metaResult.Overview;
Expand Down
Binary file modified Project/bin/Debug/Pecee.Emby.Plugin.Vod.dll
Binary file not shown.
Binary file modified Project/bin/Debug/Pecee.Emby.Plugin.Vod.pdb
Binary file not shown.
Binary file removed Project/bin/Debug/Pecee.Plugin.Emby.Vod.dll
Binary file not shown.
Binary file removed Project/bin/Debug/Pecee.Plugin.Emby.Vod.pdb
Binary file not shown.
Binary file modified Project/bin/Release/MediaBrowser.Common.dll
Binary file not shown.
Binary file modified Project/bin/Release/MediaBrowser.Controller.dll
Binary file not shown.
Binary file modified Project/bin/Release/MediaBrowser.Model.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Project/bin/Release/Pecee.Emby.Plugin.Vod.dll
Binary file not shown.
Binary file modified Project/bin/Release/Pecee.Emby.Plugin.Vod.pdb
Binary file not shown.
Binary file modified Project/obj/Debug/Pecee.Emby.Plugin.Vod.dll
Binary file not shown.
Binary file modified Project/obj/Debug/Pecee.Emby.Plugin.Vod.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion Project/obj/Debug/Project.csproj.CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8fc74df0a86ca52088d2ebdb315a00abb6712b87
b43cf14c7b9078dec8bc7dd76460ba50023cb672
Loading

0 comments on commit 3c0b369

Please sign in to comment.