Skip to content

Commit

Permalink
Write playlist details to the output file
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlendea committed Oct 18, 2020
1 parent 497f682 commit 3ab6ac9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Configuration/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public sealed class ApplicationSettings

public bool AreTvGuideTagsEnabled { get; set; }

public bool ArePlaylistDetailsTagsEnabled { get; set; }

public string UserAgent { get; set; }
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The settings are stored in the `appsettings.json` file in the root directory.
- *daysToCheck*: How far in the past to go for each playlist. If today's playlist is not found (sometimes the providers skip some days) then the service will move on to the previous day, again and again until one is found or the daysToCheck limit is reached.
- *canIncludeUnmatchedChannels*: Boolean value indicating whether provider channels that were not able to be matched with the data in the channelStorePath file should be included in the output file (in the Unknown category) or not at all
- *areTvGuideTagsEnabled*: Boolean value indicating whether TV Guide tags (logo URLs, groups, TVG IDs, channel numbers, etc) should be included in the output file or not
- *arePlaylistDetailsTagsEnabled*: Boolean value indicating whether playlist details (playlist ID, the playlist's original channel name) should be included in the output file or not
- *userAgent*: String value indicating the UserAgent that should be used when performing HTTP operations

### Channel data
Expand Down
4 changes: 4 additions & 0 deletions Service/Models/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public sealed class Channel

public int Number { get; set; }

public string PlaylistId { get; set; }

public string PlaylistChannelName { get; set; }

public string Url { get; set; }
}
}
2 changes: 2 additions & 0 deletions Service/PlaylistAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ IEnumerable<Channel> GetEnabledChannels(IEnumerable<Channel> filteredProviderCha
channel.Country = channelDef.Country;
channel.Group = groups[channelDef.GroupId].Name;
channel.LogoUrl = channelDef.LogoUrl;
channel.PlaylistId = matchedChannel.PlaylistId;
channel.PlaylistChannelName = matchedChannel.PlaylistChannelName;
channel.Url = matchedChannel.Url;

channels.Add(channel);
Expand Down
6 changes: 4 additions & 2 deletions Service/PlaylistFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ public async Task<Playlist> FetchProviderPlaylistAsync(PlaylistProvider provider
return null;
}

if (!string.IsNullOrWhiteSpace(provider.ChannelNameOverride))
foreach (Channel channel in playlist.Channels)
{
foreach (Channel channel in playlist.Channels)
channel.PlaylistId = provider.Id;

if (!string.IsNullOrWhiteSpace(provider.ChannelNameOverride))
{
channel.Name = provider.ChannelNameOverride;
}
Expand Down
15 changes: 15 additions & 0 deletions Service/PlaylistFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public sealed class PlaylistFileBuilder : IPlaylistFileBuilder
const string TvGuideLogoTagKey = "tvg-logo";
const string TvGuideCountryTagKey = "tvg-country";
const string TvGuideGroupTagKey = "group-title";
const string PlaylistIdTagKey = "playlist-id";
const string PlaylistChannelNameTagKey = "playlist-channel-name";
const int DefaultEntryRuntime = -1;

readonly ICacheManager cache;
Expand Down Expand Up @@ -48,6 +50,11 @@ public string BuildFile(Playlist playlist)
file += BuildTvGuideHeaderTags(channel);
}

if (settings.ArePlaylistDetailsTagsEnabled)
{
file += BuildPlaylistDetailsHeaderTags(channel);
}

file +=
$"{EntryValuesSeparator}{channel.Name}{Environment.NewLine}" +
$"{channel.Url}{Environment.NewLine}";
Expand Down Expand Up @@ -102,6 +109,7 @@ public Playlist ParseFile(string content)

Channel channel = new Channel();
channel.Name = lineSplit[lineSplit.Length - 1];
channel.PlaylistChannelName = channel.Name;

playlist.Channels.Add(channel);
}
Expand Down Expand Up @@ -151,5 +159,12 @@ string BuildTvGuideHeaderTags(Channel channel)

return tvgTags;
}

string BuildPlaylistDetailsHeaderTags(Channel channel)
{
return
$" {PlaylistIdTagKey}=\"{channel.PlaylistId}\"" +
$" {PlaylistChannelNameTagKey}=\"{channel.PlaylistChannelName}\"";
}
}
}
1 change: 1 addition & 0 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"daysToCheck": "7",
"canIncludeUnmatchedChannels": "true",
"areTvGuideTagsEnabled": "true",
"arePlaylistDetailsTagsEnabled": "true",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
},
"cacheSettings": {
Expand Down

0 comments on commit 3ab6ac9

Please sign in to comment.