mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* configure channel and global fallback filler * play random item from configured channel/global fallback filler as neededpull/460/head
24 changed files with 4127 additions and 49 deletions
@ -0,0 +1,51 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using ErsatzTV.Core.Domain; |
||||||
|
using ErsatzTV.Core.Interfaces.Repositories; |
||||||
|
|
||||||
|
namespace ErsatzTV.Core.Scheduling |
||||||
|
{ |
||||||
|
public static class MediaItemsForCollection |
||||||
|
{ |
||||||
|
public static async Task<List<MediaItem>> Collect( |
||||||
|
IMediaCollectionRepository mediaCollectionRepository, |
||||||
|
ITelevisionRepository televisionRepository, |
||||||
|
IArtistRepository artistRepository, |
||||||
|
CollectionKey collectionKey) |
||||||
|
{ |
||||||
|
switch (collectionKey.CollectionType) |
||||||
|
{ |
||||||
|
case ProgramScheduleItemCollectionType.Collection: |
||||||
|
List<MediaItem> collectionItems = |
||||||
|
await mediaCollectionRepository.GetItems(collectionKey.CollectionId ?? 0); |
||||||
|
return collectionItems; |
||||||
|
case ProgramScheduleItemCollectionType.TelevisionShow: |
||||||
|
List<Episode> showItems = |
||||||
|
await televisionRepository.GetShowItems(collectionKey.MediaItemId ?? 0); |
||||||
|
return showItems.Cast<MediaItem>().ToList(); |
||||||
|
case ProgramScheduleItemCollectionType.TelevisionSeason: |
||||||
|
List<Episode> seasonItems = |
||||||
|
await televisionRepository.GetSeasonItems(collectionKey.MediaItemId ?? 0); |
||||||
|
return seasonItems.Cast<MediaItem>().ToList(); |
||||||
|
case ProgramScheduleItemCollectionType.Artist: |
||||||
|
List<MusicVideo> artistItems = |
||||||
|
await artistRepository.GetArtistItems(collectionKey.MediaItemId ?? 0); |
||||||
|
return artistItems.Cast<MediaItem>().ToList(); |
||||||
|
case ProgramScheduleItemCollectionType.MultiCollection: |
||||||
|
List<MediaItem> multiCollectionItems = |
||||||
|
await mediaCollectionRepository.GetMultiCollectionItems( |
||||||
|
collectionKey.MultiCollectionId ?? 0); |
||||||
|
return multiCollectionItems; |
||||||
|
case ProgramScheduleItemCollectionType.SmartCollection: |
||||||
|
List<MediaItem> smartCollectionItems = |
||||||
|
await mediaCollectionRepository.GetSmartCollectionItems( |
||||||
|
collectionKey.SmartCollectionId ?? 0); |
||||||
|
return smartCollectionItems; |
||||||
|
default: |
||||||
|
return new List<MediaItem>(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,68 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Migrations |
||||||
|
{ |
||||||
|
public partial class Add_ChannelFallbackFiller : Migration |
||||||
|
{ |
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropForeignKey( |
||||||
|
name: "FK_Channel_ChannelWatermark_WatermarkId", |
||||||
|
table: "Channel"); |
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>( |
||||||
|
name: "FallbackFillerId", |
||||||
|
table: "Channel", |
||||||
|
type: "INTEGER", |
||||||
|
nullable: true); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
name: "IX_Channel_FallbackFillerId", |
||||||
|
table: "Channel", |
||||||
|
column: "FallbackFillerId"); |
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey( |
||||||
|
name: "FK_Channel_ChannelWatermark_WatermarkId", |
||||||
|
table: "Channel", |
||||||
|
column: "WatermarkId", |
||||||
|
principalTable: "ChannelWatermark", |
||||||
|
principalColumn: "Id", |
||||||
|
onDelete: ReferentialAction.SetNull); |
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey( |
||||||
|
name: "FK_Channel_FillerPreset_FallbackFillerId", |
||||||
|
table: "Channel", |
||||||
|
column: "FallbackFillerId", |
||||||
|
principalTable: "FillerPreset", |
||||||
|
principalColumn: "Id", |
||||||
|
onDelete: ReferentialAction.SetNull); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropForeignKey( |
||||||
|
name: "FK_Channel_ChannelWatermark_WatermarkId", |
||||||
|
table: "Channel"); |
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey( |
||||||
|
name: "FK_Channel_FillerPreset_FallbackFillerId", |
||||||
|
table: "Channel"); |
||||||
|
|
||||||
|
migrationBuilder.DropIndex( |
||||||
|
name: "IX_Channel_FallbackFillerId", |
||||||
|
table: "Channel"); |
||||||
|
|
||||||
|
migrationBuilder.DropColumn( |
||||||
|
name: "FallbackFillerId", |
||||||
|
table: "Channel"); |
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey( |
||||||
|
name: "FK_Channel_ChannelWatermark_WatermarkId", |
||||||
|
table: "Channel", |
||||||
|
column: "WatermarkId", |
||||||
|
principalTable: "ChannelWatermark", |
||||||
|
principalColumn: "Id", |
||||||
|
onDelete: ReferentialAction.Restrict); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue