Compare commits

...

220 Commits

Author SHA1 Message Date
Jason Dove
f62e841af4 update changelog for release v0.8.7-beta [no ci] 2024-06-26 22:11:36 -05:00
Jason Dove
109960c457 fix some more search queries (#1763) 2024-06-26 22:08:59 -05:00
Jason Dove
6858103be5 fix transcoding 10-bit source content using qsv on windows (#1762) 2024-06-26 16:21:42 -05:00
Jason Dove
f7f1a0493b update macos submodule again 2024-06-25 10:43:31 -05:00
Jason Dove
6c18648fd7 update macos submodule (#1760) 2024-06-25 10:31:37 -05:00
Jason Dove
ab3afcfad0 use ffmpeg 6.1 everywhere instead of ffmpeg 7 (#1754) 2024-06-21 12:30:07 -05:00
Jason Dove
5734356d29 fix template and deco template editors with mysql (#1750) 2024-06-17 15:36:14 -05:00
Jason Dove
beee038be3 fix video_bit_depth search field for plex media (#1745) 2024-06-10 15:46:23 -05:00
Jason Dove
a5c8e2b401 fix duration scheduling bug (#1744) 2024-06-10 12:30:56 -05:00
Jason Dove
c8113bdf25 fix vaapi decoder capability check (#1740)
* fix decoder video profile check

* clarify changelog
2024-06-04 06:10:02 -05:00
Jason Dove
9466cf7626 update vaapi docker bundled ffmpeg (#1729) 2024-05-25 12:13:05 -05:00
Jason Dove
43fcf9e63a upgrade to ffmpeg 7 on windows (#1727) 2024-05-24 11:31:28 -05:00
Jason Dove
242a7ae382 add b-frames option to ffmpeg profile (#1726)
* add b-frames option to ffmpeg profile

* update dependencies

* cleanup
2024-05-24 08:50:11 -05:00
Jason Dove
6dc526a817 fix dotnet in vaapi docker (#1724) 2024-05-23 07:38:01 -05:00
Jason Dove
182c02b865 use ffmpeg 7 with vaapi again (#1723) 2024-05-22 20:09:38 -05:00
Jason Dove
7c1f0d6dbd treat mid-roll as post-roll when chapter markers are missing (#1722) 2024-05-21 15:51:35 -05:00
Jason Dove
2c97c49763 custom config folders env vars (#1714)
* use custom config folder location

* allow customizing config and transcode folder locations
2024-05-10 09:28:58 -05:00
Jason Dove
f5038c2b66 play all items in playlist before starting again (#1711) 2024-05-07 17:05:12 -05:00
Jason Dove
85eb7623da fix playlist playouts (#1709)
* fix playlist playouts

* remove some logging
2024-05-06 20:40:10 -05:00
Jason Dove
a87ec2d75d cleanup (#1708)
* fix blazor naming

* code cleanup

* update dependencies
2024-05-06 17:00:52 -05:00
Jason Dove
ef6c8b0816 allow clearing (omitting) video profile setting (#1706) 2024-05-05 19:23:26 -05:00
Jason Dove
dc3578660f fix flood playout item watermark (#1705) 2024-05-05 09:08:08 -05:00
Jason Dove
ce958bb7bb enable video profile editing for qsv (#1704) 2024-05-05 08:53:34 -05:00
Jason Dove
33a8b29a27 fix block playout random seeds (#1703) 2024-05-04 09:09:04 -05:00
Jason Dove
48a504735c fix xmltv generation when no block items are selected for guide (#1702) 2024-05-03 09:18:06 -05:00
Jason Dove
0b64e97df6 fix media card (#1701) 2024-05-02 16:38:20 -05:00
Jason Dove
5d89f5d0a4 fix template editors (#1700) 2024-05-02 12:59:13 -05:00
Jason Dove
50a6ed4cea fix docker again 2024-05-02 10:31:01 -05:00
Jason Dove
66b8c8aa0e fix docker builds (#1699) 2024-05-02 10:23:07 -05:00
Jason Dove
398a3c041a detect /dev/dri/card* devices (#1698)
* remove unused nupkg

* cleanup obsolete properties

* detect /dev/dri/card devices
2024-05-02 10:17:38 -05:00
Jason Dove
6ce7265427 add qodana workflow (#1697) 2024-05-02 08:34:17 -05:00
Jason Dove
b4fe38d4ae segmenter v2 fixes (#1696) 2024-05-01 12:53:56 -05:00
Jason Dove
e19b639527 add playlist item play all option (#1694) 2024-04-28 13:00:22 -05:00
Jason Dove
a6d5df3ca6 more add to playlist buttons; fix playlist preview (#1693) 2024-04-28 08:59:14 -05:00
Jason Dove
202ae33e37 add individual media items to playlists (#1692)
* add movies to playlists

* add search results to playlist

* update changelog
2024-04-28 06:33:57 -05:00
Jason Dove
c46b3787d8 set guide mode filler as appropriate on playlist items (#1691) 2024-04-27 20:31:03 -05:00
Jason Dove
706a2d14a2 add playlists (#1690)
* update dependencies

* add playlists

* add playlist support to schedules

* playout builder (flood) supports playlists

* update changelog
2024-04-27 19:58:40 -05:00
Jason Dove
11f99216a3 fix plex library scans with mysql/mariadb (#1689) 2024-04-24 13:16:53 -05:00
Jason Dove
b9a7ad2f5a add video presets for nvenc, qsv, software h264 and hevc encoders (#1688)
* add video preset to ffmpeg profile

* add some hevc video presets
2024-04-23 14:26:30 -05:00
Jason Dove
07e7e5fe66 fix block playout playback when no deco is configured (#1687) 2024-04-23 13:10:11 -05:00
Jason Dove
4a19d046e4 fix mysql db migrations 2024-04-22 22:40:53 -05:00
Jason Dove
c1d6ddcc57 add h264 profile option to ffmpeg profile (#1686)
* add video profile for nvenc/software h264 encoders

* add h264 profile for all other encoders

* update changelog
2024-04-22 22:03:18 -05:00
Jason Dove
35eb200aee more segmenter v2 improvements (#1685)
* more segmenter v2 improvements

* changelog updates
2024-04-21 19:17:06 -05:00
Jason Dove
19af303d76 improve segmenter v2 hevc compliance with fmp4 (#1684) 2024-04-21 10:01:11 -05:00
Jason Dove
da20393a39 allow m3u8 playlist head requests (#1683) 2024-04-21 08:18:05 -05:00
Jason Dove
d78110f6f1 fix macos config folder regression (#1682)
* migrate macos config folder on startup, if needed

* add macos config folder health check

* update macos fix; update changelog
2024-04-17 09:18:09 -05:00
Jason Dove
c1bedb661c rever vaapi docker to ffmpeg 6.1 (#1681) 2024-04-16 22:27:26 -05:00
Jason Dove
d31d6f20cf upgrade to ffmpeg 7 in all docker images (#1680)
* upgrade nvidia docker to ffmpeg 7

* upgrade all docker images to ffmpeg 7

* update changelog
2024-04-16 18:24:40 -05:00
Jason Dove
7469559bb3 fix external subtitle detection (#1679) 2024-04-15 12:31:06 -05:00
Jason Dove
af5dc0968b add xmltv days to build setting (#1678) 2024-04-12 09:44:08 -05:00
Jason Dove
6e7880386b update plex show title (#1677)
* update plex show title when changed in plex

* fix test build
2024-04-12 09:21:11 -05:00
Jason Dove
8945a87f9b fix segmenter semaphore (#1676)
* disable dead air watermarks by default

* fix session worker semaphore

* update changelog
2024-04-11 19:38:57 -05:00
Jason Dove
e305222141 add dead air fallback to deco system (#1668)
* add dead air fallback to deco editor

* fix deco watermark logic

* use dead air fallback from decos
2024-04-05 23:11:14 -05:00
Jason Dove
2e2523c380 another wildcard search fix (#1667) 2024-04-05 09:12:46 -05:00
Jason Dove
b461631be9 properly update plex part keys (#1666) 2024-04-04 22:40:21 -05:00
Jason Dove
19fc068a73 add deco system (#1665)
* add deco groups and decos; set default deco for block playout

* use block playout default deco for watermark

* add deco templates, groups and deco template editor

* associate deco template with playout template

* use deco template item watermark for playback

* update changelog for decos
2024-04-04 14:38:56 -05:00
Jason Dove
e5f15df196 rework active date range; add tests (#1664) 2024-04-03 13:43:20 -05:00
Jason Dove
6ac2384cbc add active date range to block playout templates editor (#1663)
* update dependencies

* add active date range to block playout templates editor
2024-04-03 10:50:43 -05:00
Jason Dove
cd6673da82 update changelog for v0.8.6-beta [no ci] 2024-04-03 05:04:35 -05:00
Jason Dove
8113827802 allow block durations with 5-minute increments (#1662) 2024-04-02 10:27:27 -05:00
Jason Dove
4e56117e0e use jwt for mpeg-ts streaming mode (#1661) 2024-03-29 21:36:49 -05:00
Jason Dove
7702999b9a properly restore all local library items from trash during scans (#1660) 2024-03-29 20:03:19 -05:00
Jason Dove
14a707a4e2 improve plex item change detection (#1659) 2024-03-29 15:15:42 -05:00
Jason Dove
340ab61a26 add more logging to other video library scans (#1658) 2024-03-29 14:02:12 -05:00
Jason Dove
d91d991251 always interpret asterisk as wildcard search (#1657) 2024-03-29 13:27:18 -05:00
Jason Dove
3ce341eee5 fix build error for single file artifacts (#1656) 2024-03-29 12:21:58 -05:00
Jason Dove
476fe991b6 other video library scanner improvements (#1655)
* improve scanner detection when developing on macos

* support ogv files in local libraries

* improve health check wording

* try to properly restore other videos that are no longer missing
2024-03-29 12:00:46 -05:00
Jason Dove
39df3504fc content rating shouldn't ever be a phrase (#1653) 2024-03-22 09:43:51 -05:00
Jason Dove
60bb369d0c add search query parser (#1652)
* add search query parser

* add some search tests; use consistent analyzers for indexing and searching
2024-03-22 09:41:08 -05:00
Jason Dove
aae704f3a5 fix searching id fields (#1651) 2024-03-21 19:33:50 -05:00
Jason Dove
a45583d77a fix type and tag searches (#1649) 2024-03-20 22:52:16 -05:00
Jason Dove
923b36604c fix many search queries (#1648) 2024-03-20 22:29:51 -05:00
Jason Dove
b21d16b0f1 add show_content_rating to search index (#1647) 2024-03-20 19:46:19 -05:00
Jason Dove
a5aaceeee5 fix path replacement logic with inconsistent casing (#1646) 2024-03-19 08:50:00 -05:00
Jason Dove
e52d45fcf8 fix mysql migration (#1645)
* update dependencies; resync mysql db

* manually fix mysql migration
2024-03-18 11:09:27 -05:00
Jason Dove
21d39bc26f fix multi collection editor id collision (#1644) 2024-03-15 09:48:01 -05:00
Jason Dove
233a1c228a fix block creation (#1643)
* fix block creation

* update dependencies
2024-03-13 08:32:58 -05:00
Jason Dove
56988be57b properly isolate library folders between library paths (#1642) 2024-03-10 20:06:37 -05:00
Jason Dove
aded03d962 fix deleting local libraries and local library paths (#1640) 2024-03-09 12:12:22 -06:00
Jason Dove
2119c88c97 always downsample after loudnorm (#1639) 2024-03-07 09:15:02 -06:00
Jason Dove
a5d83a970a use mkv container for 8-bit segmenter v2 content (#1637) 2024-03-06 12:42:48 -06:00
Jason Dove
986785d863 always use nv12 for 8 bit vaapi encoding (#1636) 2024-03-06 12:03:14 -06:00
Jason Dove
087901d177 adjust block unique constraint (#1634)
* upgrade dependencies

* allow blocks with same name in different groups

* code cleanup
2024-03-05 10:39:06 -06:00
Jason Dove
70c4036dc9 fix ten bit source and destination with segmenter v2 (#1633)
* fix software and vaapi 10 bit content

* fix nvidia 10 bit content

* some qsv improvements
2024-03-04 15:29:45 -06:00
Jason Dove
955add1efd fix av1 software decoder priority (#1632) 2024-03-03 22:29:25 -06:00
Jason Dove
99cd01f73b update iptv routing (#1631) 2024-03-02 22:16:46 -06:00
Jason Dove
ef29e8c5a1 fix vaapi transcoding with a53 cc data (#1625) 2024-02-23 11:27:51 -06:00
Jason Dove
3b4c993530 add xmltv time zone option (#1624) 2024-02-21 12:46:09 -06:00
Jason Dove
bcc58bd668 allow segmenter v2 playback on intel vaapi/qsv (#1623) 2024-02-20 15:45:59 -06:00
Jason Dove
6957a76156 fix concat segmenter for nvidia and qsv (#1622) 2024-02-19 15:29:19 -06:00
Jason Dove
4bafc316cc fix playlist for segmenter v2 (#1621) 2024-02-19 14:11:06 -06:00
Jason Dove
35817f09ac add hls segmenter v2 streaming mode (#1620)
* concat segmenter process kind of works

* segmenter v2 improvements

* rework to allow hw accel in concat segmenter

* remove shortest; use different audio alignment filter

* hls v2 improvements

* fix tests

* update changelog
2024-02-19 13:59:33 -06:00
Jason Dove
f4520a5520 allow decimal image duration (#1619)
* add missing mysql migration

* allow decimal image duration
2024-02-16 20:01:40 -06:00
Jason Dove
3a906816fc allow playback of items with duration of 1 second (#1618) 2024-02-16 13:41:52 -06:00
Jason Dove
707292c50f add configurable image duration (#1617) 2024-02-16 13:05:28 -06:00
Jason Dove
71e9ea867a store local library folder hierarchy in db (#1616) 2024-02-16 06:16:19 -06:00
Jason Dove
c490832f66 fix episode artwork in channel guide (#1613) 2024-02-14 20:21:46 -06:00
Jason Dove
e00568cc23 fix build error (#1612) 2024-02-13 10:51:17 -06:00
Jason Dove
356e0f101a fix edge case where channel would fail to start (#1611) 2024-02-13 10:01:02 -06:00
Jason Dove
1f6e843a26 fix segmenter timestamp continuity (#1610) 2024-02-12 08:50:18 -06:00
Jason Dove
9587692486 optimize image playback (#1609) 2024-02-11 12:54:18 -06:00
Jason Dove
f8c4f44216 add basic image library support (#1608)
* add basic image library support

* add image page

* update changelog
2024-02-11 11:24:19 -06:00
Jason Dove
d55ba235bf evenly divide epg time for schedule blocks (#1607)
* add checkbox to include block items in program guide

* evenly divide epg time for schedule blocks
2024-02-10 20:59:29 -06:00
Jason Dove
60b479e330 scanning fixes (#1606)
* fix music video fallback metadata

* properly re-scan song metadata
2024-02-10 06:44:27 -06:00
Jason Dove
b866d07911 fix song libraries using string collections (#1605) 2024-02-09 13:38:54 -06:00
Jason Dove
93db79f8c4 load song comment (#1604) 2024-02-09 11:37:55 -06:00
Jason Dove
a15854d0ad more guide templates; new song metadata library (#1603)
* refactor template processing

* use template for song xmltv entries

* use template for other video xmltv entries

* update changelog
2024-02-09 11:27:44 -06:00
Jason Dove
c743d07425 include external subtitles in search index (#1602) 2024-02-07 13:28:43 -06:00
Jason Dove
8c3b8e81ca separate request logging into its own category (#1601) 2024-02-07 08:40:31 -06:00
Jason Dove
49050a57d2 load music video artists for channel guide template (#1600) 2024-02-06 10:46:34 -06:00
Jason Dove
49c53c5c96 add stale issue workflow (#1599) 2024-02-05 22:00:57 -06:00
Jason Dove
1510c56e69 generate music video xmltv fragment from template (#1598)
* generate music video xmltv fragment from template

* load all music video data
2024-02-05 19:56:19 -06:00
Jason Dove
3ec610d65f properly encode xmltv fragments (#1597) 2024-02-05 18:15:38 -06:00
Jason Dove
69f9b6f137 add channel guide templates (#1596)
* generate channels xmltv fragment from template

* generate movie xmltv fragment from template

* generate episode xmltv fragment from template

* add channel guide template changelog
2024-02-05 14:55:08 -06:00
Jason Dove
08837bda80 properly categorize some existing streaming debug logs (#1595)
* properly categorize some existing streaming debug logs

* cleanup
2024-02-05 06:37:48 -06:00
Jason Dove
9089e2ee04 add iptv request logging (#1594) 2024-02-04 21:34:41 -06:00
Jason Dove
abed22b560 prevent unnecessary search index updates (#1592)
* add sub_language and sub_language_tag fields to search index

* prevent unnecessary search index updates

* update changelog

* update dependencies
2024-02-02 06:33:06 -06:00
Jason Dove
e0f9ab4b88 batch search index updates (#1591) 2024-02-01 21:30:33 -06:00
Jason Dove
231a214223 add new subtitle settings (#1590) 2024-02-01 11:45:22 -06:00
Jason Dove
82bfa8019e tweak subtitle display in media info (#1589) 2024-01-31 19:17:04 -06:00
Jason Dove
d9bbe4df1b auto generate jwt token for channel preview (#1588) 2024-01-31 15:08:23 -06:00
Jason Dove
e0aa44d41b fix updating jellyfin movies (#1587) 2024-01-31 13:38:35 -06:00
Jason Dove
3d99c2593d allow previewing jwt channels (#1586) 2024-01-31 12:03:04 -06:00
Jason Dove
d6dfc1edaa persist data protection keys in etv config folder (#1585) 2024-01-30 19:41:39 -06:00
Jason Dove
7d5cd229d4 add show_studio search field (#1584) 2024-01-30 16:50:57 -06:00
Jason Dove
cd0219c5c3 update changelog for release v0.8.5-beta [no ci] 2024-01-30 15:34:28 -06:00
Jason Dove
4cf8b83de4 ignore subtitles when they are unavailable (#1583) 2024-01-30 14:29:13 -06:00
Jason Dove
6923b25177 add more log level switches (#1582)
* label block and json playouts as experimental

* add more log level switches
2024-01-30 13:10:19 -06:00
Jason Dove
5dce905b8e clear block playout items without clearing history (#1581) 2024-01-30 09:10:49 -06:00
Jason Dove
46c26b5ea7 include all block playout items in xmltv (#1580)
* include all block playout items in xmltv

* double check whether channel preview will work
2024-01-30 06:44:19 -06:00
Jason Dove
7fffc8cf63 channel preview player (#1579)
* add channel preview

* add button to stop transcoding session
2024-01-29 20:52:52 -06:00
Jason Dove
18deff0b83 add session api endpoints (#1578) 2024-01-29 11:31:16 -06:00
Jason Dove
16007a888e fix actions and changelog (#1576) 2024-01-27 10:14:53 -06:00
Jason Dove
7eb1227ba4 fix action version (#1575) 2024-01-26 06:17:55 -06:00
Jason Dove
1d1d5bf9bc use software overlay for intermittent watermark on nvidia (#1574)
* use software overlay for intermittent watermark on nvidia

* update some github action versions

* update changelog
2024-01-26 06:16:00 -06:00
Jason Dove
45c04366c9 remove dynaudnorm filter (#1573) 2024-01-25 19:56:14 -06:00
Jason Dove
60b3bc92f4 use super shuffle in block playouts (#1572) 2024-01-24 15:29:19 -06:00
Jason Dove
12234c3e21 allow shuffling block items (#1571)
* allow shuffling block items

* fix drop down search results
2024-01-23 22:42:28 -06:00
Jason Dove
d37ce2d38a update xmltv channel list on channel edit (#1570) 2024-01-23 13:10:52 -06:00
Jason Dove
6f49233864 fix image upload corruption (#1569) 2024-01-23 10:49:19 -06:00
Will
a67a6047c1 Update README.md (#1567)
Remove the link for Hardware-accelerated transcoding which was just linking back to itself
2024-01-22 14:33:16 -06:00
Jason Dove
33f67b88f0 show chapter markers in media info (#1568) 2024-01-22 14:19:35 -06:00
Jason Dove
b88deaafe5 add tests, replace playout items when collections are updated (#1566) 2024-01-22 10:10:22 -06:00
Jason Dove
83fc3081d8 add some logging around playlist trimming (#1565) 2024-01-22 05:47:00 -06:00
Jason Dove
15d4b0f82b remove v2 ui and node (#1564) 2024-01-16 13:28:46 -06:00
Jason Dove
88fac0de04 add option to stop scheduling before or after block duration end (#1563) 2024-01-16 12:53:56 -06:00
Jason Dove
4805d0d40f add button to copy block item (#1562) 2024-01-16 10:30:50 -06:00
Jason Dove
ef3b941a39 fix mysql migration (#1561)
* clean up block playout preview logic

* fix some bugs with playout templates editor

* fix mysql migration
2024-01-16 05:40:29 -06:00
Jason Dove
a59f71039c preview block playout in block editor (#1558)
* block editor cleanup

* preview block playout

* cleanup
2024-01-15 19:39:18 -06:00
Jason Dove
1ad42fffb1 fix mac builds (#1557) 2024-01-15 10:29:07 -06:00
Jason Dove
2ce8db9e01 basic block duration enforcement (#1556) 2024-01-15 06:26:14 -06:00
Jason Dove
c409fd8b47 fix playout build hang for block playouts (#1555) 2024-01-14 19:40:29 -06:00
Jason Dove
907b8074f1 allow more collection types and playback orders in blocks (#1554) 2024-01-14 12:51:45 -06:00
Jason Dove
adbd0bcec0 block schedule refactor (#1553)
* erase block playout history and items from playouts page

* remove block from template

* refactor block scheduling; improve history behavior
2024-01-14 10:22:04 -06:00
Jason Dove
2c4379886a limit blocks to television shows and seasons (#1551) 2024-01-14 06:46:38 -06:00
Jason Dove
caef4a139e block scheduling skip unchanged blocks (#1550)
* schedule blocks in order

* block minutes must be multiple of 15

* improve block minutes entry, validation and display

* confirm deleting blocks and block groups

* confirm deleting templates and template groups

* skip unchanged blocks in playout
2024-01-14 06:16:53 -06:00
Jason Dove
dcbe4837bf first pass at block scheduling (#1548)
* add blocks, block groups

* basic block and block item editing

* add template groups and basic template editing (name)

* add blocks to template calendar

* edit playout templates

* add calendar preview to playout templates

* add basic block playout building

* add mysql migration

* update changelog
2024-01-13 22:01:21 -06:00
Jason Dove
5e530b9301 fix scale behavior crop with qsv (#1546) 2024-01-12 13:21:49 -06:00
Jason Dove
2a28bf68bf fix crop mode with nvidia accel (#1545) 2024-01-11 11:42:26 -06:00
Jason Dove
f39eac97c0 fix fill with group when show is also included individually (#1544) 2024-01-11 10:44:50 -06:00
Jason Dove
9fd6589831 disambiguate seasons (#1543) 2024-01-11 09:08:52 -06:00
Jason Dove
e2a516f5e8 fix external json playouts with mysql (#1542) 2024-01-09 05:26:57 -06:00
Jason Dove
64502315a3 generate xmltv for external json playouts (#1541) 2024-01-08 20:54:40 -06:00
Jason Dove
56bc58fce9 reorganize to fix build (#1540) 2024-01-08 20:00:35 -06:00
Jason Dove
0330b9326d add external json playout type for dizquetv interop (#1539)
* add external json playout

* basic local playback works

* fallback to streaming from plex

* update external json file

* update changelog
2024-01-08 19:45:43 -06:00
Jason Dove
6708d6b4d7 support filling with groups of song artists (#1537) 2024-01-05 10:32:04 -06:00
Jason Dove
c18be5559b fix delete old segments (#1536)
* code cleanup

* ignore errors deleting old hls segments
2024-01-04 10:42:04 -06:00
Jason Dove
18ed20e203 fix multiple zero when using fill with group (#1535) 2024-01-02 15:29:50 -06:00
Jason Dove
965c7d0eac update changelog [no ci] 2024-01-02 10:34:57 -06:00
Jason Dove
545bf1b775 fill with group (#1534)
* use browser's accept-language header

* add fill with group mode to schedule items

* update dependencies

* fixes

* fix tests
2024-01-02 10:18:49 -06:00
Jason Dove
bb299d4ee7 maybe these don't need npm (#1533) 2023-12-30 20:13:11 -06:00
Jason Dove
0e6c7d2bc3 fix npm in docker builds (#1532) 2023-12-30 20:03:29 -06:00
Jason Dove
576f0cd7e7 more dotnet 8 fixes (#1530) 2023-12-30 13:47:45 -06:00
Jason Dove
9471cb55dd upgrade from dotnet 7 to dotnet 8 (#1529)
* upgrade sdk

* fix warnings in ersatztv.ffmpeg

* fix warnings in ersatztv.core

* fix warnings in ersatztv.infrastructure

* fix warnings in ersatztv.application

* disable analysis for migrations projects

* fix warnings in ersatztv.scanner

* fix warnings in ersatztv

* upgrade project framework

* update github actions and dockerfiles
2023-12-30 13:29:57 -06:00
Jason Dove
3a84af1626 update dependencies (#1527) 2023-12-27 04:44:30 -06:00
Jason Dove
3d3bb64844 fix path replacements page with mysql (#1521) 2023-12-11 17:54:15 -06:00
Jason Dove
8fc1f36638 use explorer to open logs folder on windows (#1520) 2023-12-05 18:28:10 -06:00
Jason Dove
1823a5bae5 update changelog for release v0.8.4-beta [no ci] 2023-12-02 16:45:33 -06:00
Jason Dove
fc871e6f74 fix detection of amf hw accel on windows (#1519) 2023-12-02 09:05:02 -06:00
Jason Dove
24780cbe84 fix disappearing collection tags (#1517) 2023-11-30 20:31:37 -06:00
Jason Dove
c6ed258021 validate filler mode pad settings (#1516) 2023-11-26 12:54:06 -06:00
Jason Dove
7586647b73 fix ffmpeg version health check on windows (#1515) 2023-11-23 06:05:49 -06:00
Jason Dove
d91e945124 update changelog for release v0.8.3-beta [no ci] 2023-11-22 11:36:31 -06:00
Jason Dove
9dabffbac1 support more formats for show fallback metadata (#1514) 2023-11-21 15:52:25 -06:00
Jason Dove
d310b5c09d fix nvidia hardware decoding on windows (#1513) 2023-11-21 06:36:05 -06:00
Jason Dove
ba48b3a676 update dependencies (#1512) 2023-11-20 21:57:43 -06:00
Jason Dove
d8a51b5d6d fix season display bug (#1511) 2023-11-20 21:17:11 -06:00
Jason Dove
97674cff89 fix bug scheduling duration filler (#1510) 2023-11-20 21:02:26 -06:00
Jason Dove
4820615308 proper fix to the sdk mismatch (#1509) 2023-11-16 13:37:20 -06:00
Jason Dove
1ddf27ce88 pin dotnet sdk version used in github actions (#1508) 2023-11-16 13:21:51 -06:00
Jason Dove
cd98a89acd enable docker arm builds again (#1507) 2023-11-16 13:07:49 -06:00
Jason Dove
a2a6afc3e3 temp disable arm docker builds (#1506) 2023-11-16 09:58:46 -06:00
Jason Dove
dfaba8c7b0 use release version of ffmpeg 6.1 (#1505) 2023-11-16 09:57:13 -06:00
Jason Dove
5d11a6b46f use separate model for plex collection scanning since the api types are inconsistent (#1504) 2023-11-16 06:43:48 -06:00
Jason Dove
b95a89b11f plex collection rework (#1503)
* start to rework plex collection scanning

* sync plex collections to db

* sync plex collection items

* update changelog
2023-11-14 10:41:21 -06:00
Jason Dove
948b3735bd fix file not found music videos (#1502)
* fix indexing music videos in file not found state

* update dependencies
2023-11-14 05:50:51 -06:00
Jason Dove
5ecf271773 fix jellyfin library scan (#1501)
* update dependencies

* fix jellyfin library scan
2023-11-10 06:26:23 -06:00
Jason Dove
b287c0d6ec add jellyfin season number fallback (#1497) 2023-11-06 09:37:12 -06:00
Jason Dove
b667659c05 use notarytool directly instead of gon (#1493) 2023-11-05 07:46:15 -06:00
Jason Dove
22d3025e8e include noto cjk fonts in docker (#1492) 2023-11-05 06:15:57 -06:00
Jason Dove
8f5b181372 mysql media server library scan fixes (#1491)
* fix some mysql movie library updates

* fix some mysql show library updates

* update dependencies
2023-10-30 06:45:00 -05:00
Jason Dove
f5060522aa windows nvidia h264 workaround (#1487)
* work around bad h264_cuvid behavior on windows with ffmpeg snapshot

* use latest ffmpeg build on windows

* nvdec => cuda
2023-10-16 11:40:12 -05:00
Jason Dove
14a88bd225 optimize ffmpeg capability cache (#1486)
* minimize cached ffmpeg capabilities

* use set intersect

* try disabling work ahead on nvidia/windows
2023-10-16 08:42:26 -05:00
Jason Dove
0550c60a78 allow older ffmpeg for testing (#1485)
* allow older ffmpeg for testing

* use proper option name
2023-10-14 21:13:18 -05:00
Jason Dove
d3bdcf9bc4 allow plex personal media show libraries (#1483) 2023-10-13 13:33:10 -05:00
Jason Dove
714f68a887 add language_tag and seconds fields to search index (#1479)
* add `language_tag` and `seconds` fields to search index

* simplify
2023-10-10 20:36:50 -05:00
Jason Dove
17bed524f2 fix ui display of multiple languages (#1474) 2023-10-08 18:21:48 -05:00
Jason Dove
c3fe263978 validate hardware accel, use hw accel for error messages (#1471)
* only display supported hw accels in ffmpeg profile editor

* qsv capability improvements

* qsv fixes

* update changelog
2023-10-08 11:21:04 -05:00
Jason Dove
5291832e6c fix clipboard and logs (#1466)
* fix copy to clipboard in some cases

* improve subtitle language selection logging

* log playout item details
2023-10-06 19:36:42 -05:00
Jason Dove
b39dd693f0 update dependencies and windows ffmpeg (#1462)
* update dependencies

* update windows ffmpeg version
2023-10-05 19:14:06 -05:00
Jason Dove
46bf9ef990 fix intel vaapi pgs subtitle pixel format (#1455) 2023-09-30 13:10:23 -05:00
Jason Dove
bc845b1327 schedule filler using ticks instead of milliseconds (#1454)
* add script to set db provider

* don't extract embedded subtitles with DEBUG_NO_SYNC

* fix playout filler precision bug
2023-09-30 06:41:15 -05:00
Jason Dove
3ab8e5bc3a optimize jellyfin collection scanning (#1453) 2023-09-29 09:47:57 -05:00
Jason Dove
e8bc051f73 transcoding improvements (#1452)
* use noautoscale with vaapi encoder

* only use one input file for vaapi with radeonsi driver

* fix vaapi 8-bit to 10-bit

* fix nvidia subtitle scaling

* optimize nvidia subtitle scaling

* fix test pgs subtitle
2023-09-29 06:29:59 -05:00
Jason Dove
b008fcfd85 fix scheduling precision error (#1451)
* fix scheduling precision error

* update dependencies
2023-09-27 06:07:48 -05:00
Jason Dove
547db5fb51 add kodiprop to channels.m3u (#1448) 2023-09-26 15:47:55 -05:00
Jason Dove
58fae1b0cc add crop scaling behavior (#1443)
* add scaling behavior - crop

* fix ffmpeg version check on windows (snapshot)

* update dependencies
2023-09-22 08:23:49 -05:00
Jason Dove
694b6bbd91 scaling behavior and normalize loudness (#1439)
* update changelog [no ci]

* add ffmpeg profile scaling behavior

* update dependencies

* add normalize loudness mode

* update changelog
2023-09-21 02:46:43 -05:00
Jason Dove
e0f8b7d7ae use ffmpeg 6.1 snapshot for windows (#1435) 2023-09-14 19:33:40 -05:00
Jason Dove
b16215fcd6 improve hls throttle (#1434)
* throttle using ffmpeg option

* update ffmpeg version
2023-09-14 19:28:15 -05:00
1177 changed files with 503609 additions and 30114 deletions

View File

@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2023.2.0",
"version": "2024.1.1",
"commands": [
"jb"
]

View File

@@ -2,7 +2,7 @@
[*]
charset=utf-8
end_of_line=lf
trim_trailing_whitespace=false
trim_trailing_whitespace=true
insert_final_newline=false
indent_style=space
indent_size=4

View File

@@ -47,19 +47,9 @@ jobs:
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Cache NPM dependencies
uses: bahmutov/npm-install@v1.8.28
with:
working-directory: ErsatzTV/client-app
dotnet-version: 8.0.x
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
@@ -68,7 +58,7 @@ jobs:
run: dotnet restore -r "${{ matrix.target}}"
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
uses: Apple-Actions/import-codesign-certs@v2
with:
p12-file-base64: ${{ secrets.apple_developer_certificate_p12_base64 }}
p12-password: ${{ secrets.apple_developer_certificate_password }}
@@ -83,8 +73,8 @@ jobs:
shell: bash
run: |
sed -i '' '/Scanner/d' ErsatzTV/ErsatzTV.csproj
dotnet publish ErsatzTV.Scanner/ErsatzTV.Scanner.csproj --framework net7.0 --runtime "${{ matrix.target }}" -c Release -o publish -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=false -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
dotnet publish ErsatzTV/ErsatzTV.csproj --framework net7.0 --runtime "${{ matrix.target }}" -c Release -o publish -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=false -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
dotnet publish ErsatzTV.Scanner/ErsatzTV.Scanner.csproj --framework net8.0 --runtime "${{ matrix.target }}" -c Release -o publish -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=false -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
dotnet publish ErsatzTV/ErsatzTV.csproj --framework net8.0 --runtime "${{ matrix.target }}" -c Release -o publish -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=false -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
- name: Bundle
shell: bash
@@ -118,12 +108,8 @@ jobs:
- name: Notarize
shell: bash
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
gon -log-level=debug -log-json ./gon.json
env:
AC_USERNAME: ${{ secrets.ac_username }}
AC_PASSWORD: ${{ secrets.ac_password }}
xcrun notarytool submit ErsatzTV.dmg --apple-id "${{ secrets.ac_username }}" --password "${{ secrets.ac_password }}" --team-id 32MB98Q32R --wait
xcrun stapler staple ErsatzTV.dmg
- name: Cleanup
shell: bash
@@ -177,25 +163,9 @@ jobs:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
if: ${{ matrix.kind == 'windows' }}
- name: Cache NPM dependencies
uses: bahmutov/npm-install@v1.8.28
with:
working-directory: ErsatzTV/client-app
dotnet-version: 8.0.x
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
@@ -208,7 +178,7 @@ jobs:
id: downloadffmpeg
name: Download ffmpeg
with:
url: "https://github.com/GyanD/codexffmpeg/releases/download/6.0/ffmpeg-6.0-full_build.7z"
url: "https://github.com/ErsatzTV/ErsatzTV-ffmpeg/releases/download/6.1-working-cuvid/ffmpeg-6.1-working-cuvid.7z"
target: ffmpeg/
- name: Build
@@ -220,8 +190,8 @@ jobs:
# Build everything
sed -i '/Scanner/d' ErsatzTV/ErsatzTV.csproj
dotnet publish ErsatzTV.Scanner/ErsatzTV.Scanner.csproj --framework net7.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=true -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
dotnet publish ErsatzTV/ErsatzTV.csproj --framework net7.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=true -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
dotnet publish ErsatzTV.Scanner/ErsatzTV.Scanner.csproj --framework net8.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=true -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
dotnet publish ErsatzTV/ErsatzTV.csproj --framework net8.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=true -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true
# Build Windows launcher
if [ "${{ matrix.kind }}" == "windows" ]; then
@@ -245,9 +215,6 @@ jobs:
# Delete output directory
rm -r "$release_name"
env:
AC_USERNAME: ${{ secrets.ac_username }}
AC_PASSWORD: ${{ secrets.ac_password }}
- name: Delete old release assets
uses: mknejp/delete-release-assets@v1
@@ -259,6 +226,7 @@ jobs:
assets: |
*${{ matrix.target }}.zip
*${{ matrix.target }}.tar.gz
- name: Publish
uses: softprops/action-gh-release@v1
with:

24
.github/workflows/code_quality.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2024.1
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

View File

@@ -54,21 +54,21 @@ jobs:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
if: ${{ matrix.qemu == true }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
id: docker-buildx
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.docker_hub_username }}
password: ${{ secrets.docker_hub_access_token }}
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
builder: ${{ steps.docker-buildx.outputs.name }}
context: .
@@ -82,7 +82,7 @@ jobs:
if: ${{ matrix.name != 'arm64' && matrix.name != 'arm32v7' }}
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
builder: ${{ steps.docker-buildx.outputs.name }}
context: .
@@ -97,7 +97,7 @@ jobs:
if: ${{ matrix.name == 'arm64' }}
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
builder: ${{ steps.docker-buildx.outputs.name }}
context: .

27
.github/workflows/issue-stale.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: 'Close stale issues'
on:
schedule:
- cron: '30 1 * * *'
workflow_dispatch:
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
ascending: true
days-before-stale: 120
days-before-pr-stale: -1
days-before-close: 21
days-before-pr-close: -1
operations-per-run: 500
exempt-issue-labels: 'regression,security,roadmap,future,feature,enhancement,confirmed'
stale-issue-label: 'stale'
stale-issue-message: |-
This issue has gone 120 days without an update and will be closed within 21 days if there is no new activity. To prevent this issue from being closed, please confirm the issue has not already been fixed by providing updated examples or logs.
If you have any questions you can use one of several ways to [contact us](https://ersatztv.org).
close-issue-message: |-
This issue was closed due to inactivity.

View File

@@ -9,14 +9,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
dotnet-version: 8.0.x
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
@@ -31,7 +26,7 @@ jobs:
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --blame-hang-timeout "2m" --no-restore --verbosity normal
- name: Build Windows
run: |
@@ -44,9 +39,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
@@ -61,7 +56,7 @@ jobs:
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --blame-hang-timeout "2m" --no-restore --verbosity normal
build_and_test_mac:
runs-on: macos-11
steps:
@@ -72,9 +67,9 @@ jobs:
submodules: true
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Clean
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
@@ -89,4 +84,4 @@ jobs:
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --blame-hang-timeout "2m" --no-restore --verbosity normal

View File

@@ -1,22 +0,0 @@
name: Lint VueJS Files on PR Request
on:
pull_request:
jobs:
vue-lint:
runs-on: ubuntu-latest
steps:
# Checkout the current repo
- name: Checkout current repository
uses: actions/checkout@v4
# Setup NodeJS version 16
- name: Setup NodeJS V16.x.x
uses: actions/setup-node@v3
with:
node-version: '16'
# CD into the current client directory and lint and build the client
- name: Lint and Build the client
run: |
cd ./ErsatzTV/client-app/
npm ci --no-optional
npm run lint
npm run build --if-present

View File

@@ -1,10 +1,319 @@
# Changelog
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
## [0.8.7-beta] - 2024-06-26
### Added
- Add `Active Date Range` to block playout template editor to allow limiting templates to a specific date range
- This is year-agnostic, meaning the Month/Day range will apply to every year
- This also supports wrapping the end of the year (e.g., start 12/1 and end 1/15)
- Add new `Deco` system for "decorating" channels with non-primary content
- Decos currently contain
- Watermarks
- Dead Air Fallback (i.e. fallback filler)
- Similar to blocks, decos have deco groups for organization
- Similar to blocks, decos have deco templates for filling a "day" with decos
- In the playout template editor, playout template items can have *both* a block template and a deco template
- This allows watermarks and dead air fallback to change at different times than primary content
- Block playouts can also have a default deco
- This will apply whenever a deco template is missing, or when a deco template item cannot be found for the current time
- Effectively, this sets a default watermark and dead air fallback for the entire playout
- Add `XMLTV Days To Build` setting, which is distinct from the existing `Playout Days To Build` setting
- The value for `XMLTV Days To Build` cannot be larger than `Playout Days To Build`
- This allows, for example, a week of playout data while optimizing XMLTV data to only a day or two
- Add health check to detect config folder issue on MacOS
- ETV versions through v0.8.4-beta (using dotnet 7) stored config data in `$HOME/.local/share/ersatztv`
- ETV versions starting with v0.8.5-beta (using dotnet 8) store config data in `$HOME/Library/Application Support/ersatztv`
- If a dotnet 8 version of ETV has NOT been launched on MacOS, it will automatically migrate the config folder on startup
- If a dotnet 8 version of ETV *has* been launched on MacOS, a failing health check will display with instructions on how to resolve the config issue to restore data
- Add `Video Profile` setting to `FFmpeg Profile` editor when `h264` format is selected
- Add `Video Preset` setting to `FFmpeg Profile` editor for some combinations of acceleration and video format:
- `Nvenc` / `h264`
- `Nvenc` / `hevc`
- `Qsv` / `h264`
- `Qsv` / `hevc`
- `None` / `h264`
- `None` / `hevc`
- Add *experimental* list type `Playlist`
- Playlists contain an ordered list of:
- Collections
- Multi-Collections
- Smart Collections
- TV Shows
- TV Seasons
- Artists
- Movies
- Episodes
- Music Videos
- Other Videos
- Songs
- Images
- Playlists can be added to schedules as a schedule item
- Each time through the playlist, one item will be scheduled from each playlist item (if `Play All` is unchecked)
- NB: This does not mean every collection will always schedule one item; the normal flood playout restrictions like duration and fixed start times still apply here
- If `Play All` is checked, that playlist item will play all of its items each time through the playlist
- This can be helpful if you want to play entire collections in a specific order, e.g.
- Every episode from Show 1 Season 2
- Every episode from Show 2 Season 3
- Every episode from Show 1 Season 3
- Playlist items with fewer media items will be re-shuffled (if applicable) before those with more media items
- Add two new environment variables to customize config and transcode folder locations
- `ETV_CONFIG_FOLDER`
- `ETV_TRANSCODE_FOLDER`
- Add checkbox to allow use of B-frames in FFmpeg Profile (disabled by default)
### Fixed
- Fix some cases of 404s from Plex when files were replaced and scanning the library from ETV didn't help
- Fix more wildcard search phrase queries (when wildcards are used in quotes, like `title:"law & order*"`)
- Fix non-wildcard simple queries when asterisks are used in quotes, like `title:"m*a*s*h"`
- Fix bug where channels would unnecessarily wait on each other
- e.g. in-progress streams would delay responding with a playlist when new streams were starting
- Update Plex show title in ETV when changed in Plex
- Reindex seasons and episodes when show is updated from media server
- This is needed to keep `show_*` tags accurate in the search index (e.g., `show_title`, `show_studio`)
- Fix external subtitle detection to support forced/sdh subtitles with language tag before and after forced/sdh tag:
- `Something.forced.en.srt`
- `Something.sdh.en.srt`
- `Something.en.forced.srt`
- `Something.en.sdh.srt`
- Fix playback from Jellyfin 10.9 by allowing playlist HTTP HEAD requests
- Fix `HLS Segmenter V2` segment duration (previously 10s, now 4s)
- Fix `HLS Segmenter V2` error video generation
- Fix MySql database migrations
- Fix Plex library scans with MySql/MariaDB
- Fix block playout playback when no deco is configured
- Fix `HLS Segmenter V2` to delete old segments (use less disk space while channel is active)
- Fix template and deco template editors to prevent items that go beyond midnight
- Fix block playout random seeds
- Different blocks within a single playout will now correctly use different random seeds (shuffles)
- Erasing block playout history will also generate new random seeds for the playout
- Fix building playouts that use mid-roll filler and have content without chapter markers
- When this happens, mid-roll will be treated as post-roll
- Fix VAAPI decoder capability check
- This caused some streams to incorrectly use software decoding
- Fix scheduling loop/failure caused by some duration schedule items
- Fix `video_bit_depth` search field for Plex media
- Fix template and deco template editors with MariaDB/MySql backend
- Fix transcoding 10-bit source content using QSV acceleration on Windows
### Changed
- Show health checks at top of home page; scroll release notes if needed
- Improve `HLS Segmenter V2` compliance by:
- Serving fmp4 segments when `hevc` video format is selected
- > 1.5. The container format for HEVC video MUST be fMP4.
- Using accurate BANDWIDTH value in multi-variant playlist
- Using proper MIME types for statically-served `.m3u8` and `.ts` files
- Serving playlists with gzip compression
- Use `HLS Segmenter V2` for channel preview when channel is configured for `HLS Segmenter V2`
- Detect and use `/dev/dri/card*` devices in addition to `/dev/dri/render*` devices
- Change default folder locations in docker using new environment variables
- `ETV_CONFIG_FOLDER` - now defaults to `/config`
- `ETV_TRANSCODE_FOLDER` - now defaults to `/transcode`
- If the old locations are still present in docker, these variables will be ignored, so you can migrate at your own pace
- Old config location: `/root/.local/share/ersatztv`
- Old transcode location: `/root/.local/share/etv-transcode`
## [0.8.6-beta] - 2024-04-03
### Added
- Add `show_studio` and `show_content_rating` to search index for seasons and episodes
- Add two new global subtitle settings:
- `Use embedded subtitles`
- Default value: `true`
- When disabled, embedded subtitles will not be considered for extraction (text subtitles), or playback (all embedded subtitles)
- `Extract and use embedded (text) subtitles`
- Default value: `false`
- When enabled, embedded text subtitles will be periodically extracted, and considered for playback
- Add `sub_language` and `sub_language_tag` fields to search index
- Add `/iptv` request logging in its own log category at debug level
- Add channel guide (XMLTV) template system
- Templates should be copied from `_channel.sbntxt`, `_movie.sbntxt`, `_episode.sbntxt`, `_musicVideo.sbntxt`, `_song.sbntxt`, or `_otherVideo.sbntxt` which are located in the config subfolder `templates/channel-guide`
- Copy the file, remove the leading underscore from the name, and only make edits to the copied file
- The default templates will be extracted and overwritten every time ErsatzTV is started
- The templates use [scribian](https://github.com/scriban/scriban/tree/master/doc) template syntax
- The templates contain comments describing which fields are available for use in the templates
- Add *experimental* and *incomplete* `Images` library kind
- Image libraries have fallback metadata added like Other Video libraries (every folder is a tag)
- Image library items currently default to a duration of 15 seconds
- The `Media` > `Images` page can be used to configure image durations at a folder level
- Child folders with unset durations will inherit the closest ancestor's duration
- Add *experimental* new streaming mode `HLS Segmenter V2`
- In my initial testing, this streaming mode produces significantly fewer playback warnings/errors
- If it tests well for others, it *may* replace the current `HLS Segmenter` in a future release
- Add setting to change XMLTV data from `Local` time zone to `UTC`
- This is needed because some clients (incorrectly) ignore time zone specifier and require UTC times
- Support `.ogv` video files in local libraries
### Fixed
- Fix antiforgery error caused by reusing existing browser tabs across docker container restarts
- Data protection keys will now be persisted under ErsatzTV's config folder instead of being recreated at startup
- Fix bug updating/replacing Jellyfin movies
- A deep scan can be used to fix all movies, otherwise any future updates made to JF movies will correctly sync to ETV
- Automatically generate JWT tokens to allow channel previews of protected streams
- Fix bug applying music video fallback metadata
- Fix playback of media items with no audio streams
- Fix timestamp continuity in `HLS Segmenter` sessions
- This should make *some* clients happier
- Fix `Other Video`, `Song` and `Image` fallback metadata tags to always include parent folder (folder added to library)
- Allow playback of items with any positive duration, including less than one second
- Fix VAAPI transcoding of OTA content containing A53 CC data
- Fix AV1 software decoder priority (`libdav1d`, `libaom-av1`, `av1`)
- Fix some stream failures caused by loudnorm filter
- Fix multi-collection editor improperly disabling collections/smart collections that haven't already been added to the multi-collection
- Fix path replacement logic when media server paths use inconsistent casing (e.g. `\\SERVERNAME` AND `\\ServerName`)
- Fix *many* search queries, including actors with the name `Will`
- Fix sqlite `database is locked` error that would crash ETV on startup after search index corruption
- Fix bug where replacing files in Plex would be missed by subsequent ETV library scans
- This fix will require a one-time re-scan of each Plex library in full
- After the initial full scan, incremental scans will behave as normal
- Fix edge case where some local episodes, music videos, other videos, songs, images would not automatically be restored from trash
- Fix `MPEG-TS` playback when JWT tokens are enabled for streaming endpoints
### Changed
- Log search index updates under scanner category at debug level, to indicate a potential cause for the UI being out of date
- Batch search index updates to keep pace with library scans
- Previously, search index updates would slowly process over minutes/hours after library scans completed
- Search index updates should now complete at the same time as library scans
- Do not unnecessarily update the search index during media server library scans
- Use different library for reading song metadata that supports multiple tag entries
- Update `/iptv` routing to make UI completely inaccessible from that path prefix
- Use CUDA 11 instead of CUDA 12 in NVIDIA docker image to significantly lower required driver version
- Allow block durations with 5-minute increments (e.g., 5 min, 10 min, 15 min, etc.)
## [0.8.5-beta] - 2024-01-30
### Added
- Respect browser's `Accept-Language` header for date time display
- Add new schedule item setting `Fill With Group Mode`
- This setting is only available when a `Collection`, `Multi-Collection` or `Smart Collection` is scheduled with `Duration` or `Multiple` playout modes
- Use this setting when you want to schedule a collection containing groups (show or artists), with only videos from a single group (show or artist) being used in each rotation
- The options are `None`, `Ordered Groups` and `Shuffled Groups`:
- `None`: no change to scheduling behavior - all groups (shows and artists) will be shuffled/ordered together
- `Ordered Groups`: each time this item is scheduled, the entire `Duration` or `Multiple` will be filled with a single group, and the groups will rotate in a fixed order
- `Shuffled Groups`: each time this item is scheduled, the entire `Duration` or `Multiple` will be filled with a single group, and the groups will rotate in a shuffled order
- Add new playout type `External Json`
- Use this playout type when you want to manage the channel schedule using DizqueTV
- You must point ErsatzTV to the channel number json file from DizqueTV, e.g. `channels/1.json`
- For playback, ErsatzTV will first check for the appropriate media file file locally
- If found, ErsatzTV will run ffprobe to get statistics immediately before streaming from disk
- When local files are unavailable, ErsatzTV must be logged into the same Plex server as DizqueTV
- ErsatzTV will ask Plex for statistics immediately before streaming from Plex
- Add new *experimental* playout type `Block`
- **This playout type is under active development and updates may reset or delete related playout data**
- Many planned features are missing, incomplete, or result in errors. This is expected.
- Block playouts consist of:
- `Blocks` - ordered list of items to play within the specified duration
- `Templates` - a generic "day" that consists of blocks scheduled at specific times
- `Playout Templates` - templates to schedule using the specified criteria. Only one template will be selected each day
- Much more to come on this feature as development continues
- Show chapter markers in movie and episode media info
- Add two new API endpoints for interacting with transcoding sessions (MPEG-TS and HLS Segmenter):
- GET `/api/sessions`
- Show brief info about all active sessions
- DELETE `/api/session/{channel-number}`
- Stop the session for the given channel number
- Add channel preview (web-based video player)
- Channels MUST use `H264` video format and `AAC` audio format
- Channels MUST use `MPEG-TS` or `HLS Segmenter` streaming modes
- Since `MPEG-TS` uses `HLS Segmenter` under the hood, the preview player will use `HLS Segmenter`, so it's not 100% equivalent, but it should be representative
- Add button to stop transcoding session for each channel that has an active session
- Add more log levels to `Settings` page, allowing more specific debug logging as needed
- Default Minimum Log Level (applies when no other categories/level overrides match)
- Scanning Minimum Log Level
- Scheduling Minimum Log Level
- Streaming Minimum Log Level
### Fixed
- Fix error loading path replacements when using MySql
- Fix tray icon shortcut to open logs folder on Windows
- Unlock playout when playout build fails
- Ignore errors deleting old HLS segments; this should improve stream reliability
- Update show year when changed within Plex
- Fix crop scale behavior with NVIDIA, QSV acceleration
- Fix bug that corrupted uploaded images (watermarks, channel logos)
- Re-uploading images should fix them
- Recreate XMLTV channel list (including logos) when channels are edited in ErsatzTV
- This bug caused the ErsatzTV logo to be used instead of channel logos in some cases
- Update drop down search results in main search bar when items are created/edited/removed
- Fix green line at bottom of video when NVIDIA accel is used with intermittent watermark
- Fix error starting streaming session when subtitles are still being extracted for the current item
### Changed
- Upgrade from .NET 7 to .NET 8
- In schedule items, disambiguate seasons from shows with the same title by including show year
- Old format: `Show Title (Season Number)`
- New format: `Show Title (Show Year) - Season Number`
- Remove FFmpeg Profile `Normalize Loudness` option `dynaudnorm` as it often caused streams to fail to start
- Disable loudness normalization by default in new FFmpeg Profiles
- Use AAC audio format by default in new FFmpeg Profiles
## [0.8.4-beta] - 2023-12-02
### Fixed
- Fix playout builder crash with improperly configured pad filler preset
- Properly validate filler preset mode pad to require `filler pad to nearest minute` value
- Fix bug where previously-synchronized collection tags would disappear
- This bug affected Jellyfin, Emby and Plex collections
- Fix detection of AMF hardware acceleration on Windows
## [0.8.3-beta] - 2023-11-22
### Added
- Add `Scaling Behavior` option to FFmpeg Profile
- `Scale and Pad`: the default behavior and will maintain aspect ratio of all content
- `Stretch`: a new mode that will NOT maintain aspect ratio when normalizing source content to the desired resolution
- `Crop`: a new mode that will scale beyond the desired resolution (maintaining aspect ratio), and crop to desired resolution
- **This mode does NOT detect black and intelligently crop**
- The goal is to fill the canvas by over-scaling and cropping, instead of minimally scaling and padding
- Include `inputstream.ffmpegdirect` properties in channels.m3u when requested by Kodi
- Log playout item title and path when starting a stream
- This will help with media server libraries where the URL passed to ffmpeg doesn't indicate which file is streaming
- Add QSV Capabilities to Troubleshooting page
- Add `language_tag` and `seconds` fields to search index
- Allow synchronizing Plex `TV Show` libraries that use `Personal Media Shows` agent
- Include Noto CJK Fonts in docker images to support those characters in generated subtitles like songs and music video credits
- Support show fallback metadata with folder names like `Show.Name(1992)`
### Fixed
- Fix playout bug that caused some schedule items with fixed start times to be pushed to the next day
- Fix playout bug that prevented padded durations from fitting within a schedule item of the same duration
- For example, filler that padded to 30 minutes would often not fit in a 30 minute duration schedule item
- Fix VAAPI transcoding 8-bit source content to 10-bit
- Fix NVIDIA subtitle scaling when `scale_npp` filter is unavailable
- Remove ffmpeg and ffprobe as required dependencies for scanning media server libraries
- Note that ffmpeg is still *always* required for playback to work
- Fix PGS subtitle pixel format with Intel VAAPI
- Fix some cases where `Copy` button would fail to copy to clipboard
- Fix some cases where ffmpeg process would remain running after properly closing ErsatzTV
- Fix QSV HLS segment duration
- This behavior caused extremely slow QSV stream starts
- Fix displaying multiple languages in UI for movies, artists, shows
- Fix MySQL queries that could fail during media server library scans
- Fix scanning Jellyfin libraries when library options and/or path infos are not returned from Jellyfin API
- Fix error indexing music videos in `File Not Found` state
- Fix bug scheduling duration filler when filler collection contains item with zero duration
- Fix bug displaying television seasons for shows that have no year metadata
### Changed
- Upgrade ffmpeg to 6.1, which is now *required* for all installs
- Use new ffmpeg throttling method to minimize cpu/gpu use without impacting audio normalization
- Change FFmpeg Profile `Normalize Loudness` setting from checkbox to dropdown
- `Off`: do not normalize loudness
- `loudnorm`: use `loudnorm` filter to normalize loudness (generally higher CPU use)
- `dynaudnorm`: use `dynaudnorm` filter to normalize loudness (generally lower CPU use)
- Jellyfin collection scanning will no longer happen after every (automatic or forced) library scan
- Automatic/periodic scans will check collections one time after all libraries have been scanned
- There is a new table in the `Media` > `Libraries` page with a button to manually re-scan Jellyfin collections as needed
- In FFmpeg Profile editor, only display hardware acceleration kinds that are supported by the configured ffmpeg
- Test QSV acceleration if configured, and fallback to software mode if test fails
- Detect QSV capabilities on Linux (supported decoders, encoders)
- Use hardware acceleration for error messages/offline messages
- Try to parse season number from season folder when Jellyfin does not provide season number
- This *may* fix issues where Jellyfin libraries show all season numbers as 0 (specials)
- Rework Plex collection scanning
- Automatic/periodic scans will check collections one time after all libraries have been scanned
- There is a table in the `Media` > `Libraries` page with a button to manually re-scan Plex collections as needed
- Plex smart collections will now be synchronized as tags, similar to other Plex collections
## [0.8.2-beta] - 2023-09-14
### Added
- Automatically rebuild search index after improper shutdown
@@ -46,7 +355,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Only allow a single instance of ErsatzTV to run
- This fixes some cases where the search index would become unusable
- Fix VAAPI rate control mode capability check
- Fix VAAPI rate control mode capability check
### Changed
- Rework startup process to show UI as early as possible
@@ -92,14 +401,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `MKV` output format: stream copy any embedded subtitles
### Fixed
- Fix extracting embedded text subtitles that had been incompletely extracted in the past
- Fix extracting embedded text subtitles that had been incompletely extracted in the past
- Fix fallback filler looping by forcing software mode for this content
- Other content will still use hardware acceleration as configured
- Hardware-accelerated fallback filler may be re-enabled in the future
- Fix playout building when shuffle in order is used with a single media item
- Fix pgs subtitle burn in from media server libraries
- Fix subtitle and watermark overlays with RadeonSI VAAPI driver
- Fix NVIDIA pipeline to use hardware-accelerated decoder with 8-bit h264 content
- Fix NVIDIA pipeline to use hardware-accelerated decoder with 8-bit h264 content
### Changed
- Timeout playout builds after 2 minutes; this should prevent playout bugs from blocking other functionality
@@ -149,7 +458,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Use Poster artwork for XMLTV if available
- If Poster artwork is unavailable, use Thumbnail
- Improve XMLTV response time by caching data as playouts are updated
- Improve XMLTV response time by caching data as playouts are updated
## [0.7.6-beta] - 2023-03-24
### Added
@@ -243,13 +552,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Merge generated `Other Video` folder tags with tags from sidecar NFO
- Prioritize audio streams that are flagged as "default" when multiple candidate streams are available
- For example, a video with a stereo commentary track and a stereo "default" track will now prefer the "default" track
- For example, a video with a stereo commentary track and a stereo "default" track will now prefer the "default" track
## [0.7.3-beta] - 2023-01-25
### Added
- Attempt to release memory periodically
- Add OpenID Connect (OIDC) support (e.g. Keycloak, Authelia, Auth0)
- This only protects the management UI; all streaming endpoints will continue to allow anonymous access
- This only protects the management UI; all streaming endpoints will continue to allow anonymous access
- This can be configured with the following env vars (note the double underscore separator `__`)
- `OIDC__AUTHORITY`
- `OIDC__CLIENTID`
@@ -267,7 +576,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Day of week
- Day of month
- Month
- The lowest priority (bottom) item will always match all parameters, and can be considered a "default" or "fallback" schedule
- The lowest priority (bottom) item will always match all parameters, and can be considered a "default" or "fallback" schedule
### Fixed
- Fix schedule editor crashing due to bad music video artist data
@@ -299,7 +608,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix song playback with VAAPI and NVENC
- Fix edge case where some local movies would not automatically be restored from trash
- Fix synchronizing Jellyfin and Emby collection items
- Fix saving some external subtitle records to database
- Fix saving some external subtitle records to database
### Changed
- Upgrade to dotnet 7
@@ -377,7 +686,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Add music video credits template system
- Templates are selected in each channel's settings
- Templates are selected in each channel's settings
- Templates should be copied from `_default.ass.sbntxt` which is located in the config subfolder `templates/music-video-credits`
- Copy the file, give it any name ending with `.ass.sbntext`, and only make edits to the copied file
- The default template will be extracted and overwritten every time ErsatzTV is started
@@ -452,7 +761,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Replace `setsar` filter with `setdar` filter
- `setsar` caused issues scaling between two different aspect ratios
- For example, some 4:3 content would appear stretched when scaled to a 16:9 resolution
- `setdar` is now only used when aspect ratios match
- `setdar` is now only used when aspect ratios match
- Prioritize aspect ratio from container when video stream contains conflicting aspect ratio
- This is usually caused by bad authoring, but the change should improve scaling behavior for edge cases
@@ -555,7 +864,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Reduce memory use due to library scan operations
- Fix some instances of filler getting "stuck" when a filler item is encountered that's too long for the gap
- Properly ignore Plex `Other Videos` libraries (`movie` libraries where agent is `com.plexapp.agents.none`)
- Fix `Custom Title` for schedule items with `One`, `Multiple` and `Flood` playout modes
- Fix `Custom Title` for schedule items with `One`, `Multiple` and `Flood` playout modes
- Fix scheduling bug where flood items would sometimes fail to continue after midnight
### Added
@@ -585,7 +894,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix occasional erroneous log messages when HLS channel playback times out because all clients have left
- Fix fallback filler playback
- Fix stream continuity when error messages are displayed
- Fix duplicate scanning within `Other Video` libraries (i.e. folders would be scanned multiple times)
- Fix duplicate scanning within `Other Video` libraries (i.e. folders would be scanned multiple times)
### Added
- Add `show_genre` and `show_tag` to search index for seasons and episodes
@@ -673,7 +982,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix setting VAAPI driver name
- Fix ffmpeg troubleshooting reports
- Fix bug where filler would behave as if it were configured to pad even though a different mode was selected
- Fix bug where mid-roll count filler would skip scheduling the final chapter in an episode
- Fix bug where mid-roll count filler would skip scheduling the final chapter in an episode
### Added
- Add `Empty Trash` button to `Trash` page
@@ -980,7 +1289,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- When streaming is attempted during an unscheduled gap, the resulting video will be determined using the following priority:
- Channel fallback filler
- Global fallback filler
- Generated `Channel Is Offline` error message video
- Generated `Channel Is Offline` error message video
### Changed
- Allow per-episode folders for local show libraries
@@ -1088,7 +1397,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.1.0-alpha] - 2021-10-08
### Added
- Add *experimental* streaming mode `HLS Segmenter` (most similar to `HLS Hybrid`)
- Add *experimental* streaming mode `HLS Segmenter` (most similar to `HLS Hybrid`)
- This mode is intended to increase client compatibility and reduce issues at program boundaries
- If you want the temporary transcode files to be located on a particular drive, the docker path is `/root/.local/share/etv-transcode`
- Store frame rate with media statistics; this is needed to support HLS Segmenter
@@ -1124,7 +1433,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- See `Logs` for unmatched item details
- Trakt lists can only be scheduled by using Smart Collections
- Add seasons to search index
- This is needed because Trakt lists can contain seasons
- This is needed because Trakt lists can contain seasons
- This requires rebuilding the search index and search results may be empty or incomplete until the rebuild is complete
### Fixed
@@ -1476,7 +1785,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Limit channels to one playout per channel
- Though more than one playout was previously possible it was unsupported and unlikely to work as expected, if at all
- A future release may make this possible again
## [0.0.32-prealpha] - 2021-04-09
### Added
- `Add All To Collection` button to quickly add all search results to a collection
@@ -1741,7 +2050,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Initial release to facilitate testing outside of Docker.
[Unreleased]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.2-beta...HEAD
[Unreleased]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.7-beta...HEAD
[0.8.7-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.6-beta...v0.8.7-beta
[0.8.6-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.5-beta...v0.8.6-beta
[0.8.5-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.4-beta...v0.8.5-beta
[0.8.4-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.3-beta...v0.8.4-beta
[0.8.3-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.2-beta...v0.8.3-beta
[0.8.2-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.1-beta...v0.8.2-beta
[0.8.1-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.8.0-beta...v0.8.1-beta
[0.8.0-beta]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.7.9-beta...v0.8.0-beta
@@ -1860,4 +2174,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[0.0.5-prealpha]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.0.4-prealpha...v0.0.5-prealpha
[0.0.4-prealpha]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.0.3-prealpha...v0.0.4-prealpha
[0.0.3-prealpha]: https://github.com/ErsatzTV/ErsatzTV/compare/v0.0.1-prealpha...v0.0.3-prealpha
[0.0.1-prealpha]: https://github.com/ErsatzTV/ErsatzTV/releases/tag/v0.0.1-prealpha
[0.0.1-prealpha]: https://github.com/ErsatzTV/ErsatzTV/releases/tag/v0.0.1-prealpha

View File

@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<InformationalVersion>develop</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
</Project>

View File

@@ -43,10 +43,7 @@ fn main() {
None => {}
Some(folder) => {
fs::create_dir_all(folder).unwrap();
let _ = Command::new("cmd")
.creation_flags(CREATE_NO_WINDOW)
.arg("/C")
.arg("start")
let _ = Command::new("explorer.exe")
.arg(folder)
.stdin(Stdio::null())
.stdout(Stdio::null())

View File

@@ -29,12 +29,11 @@ internal static class Mapper
CultureInfo[] allCultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures);
return languages
.Distinct()
.Map(
lang => allCultures.Filter(
ci => string.Equals(ci.ThreeLetterISOLanguageName, lang, StringComparison.OrdinalIgnoreCase)))
.Sequence()
.Flatten()
.Distinct()
.ToList();
}
}

View File

@@ -3,8 +3,7 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.Channels;
public record CreateChannel
(
public record CreateChannel(
string Name,
string Number,
string Group,

View File

@@ -1,33 +1,38 @@
using System.Globalization;
using System.Text.RegularExpressions;
using System.Threading.Channels;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Domain.Filler;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
using Channel = ErsatzTV.Core.Domain.Channel;
namespace ErsatzTV.Application.Channels;
public class CreateChannelHandler : IRequestHandler<CreateChannel, Either<BaseError, CreateChannelResult>>
public class CreateChannelHandler(
ChannelWriter<IBackgroundServiceRequest> workerChannel,
IDbContextFactory<TvContext> dbContextFactory,
ISearchTargets searchTargets)
: IRequestHandler<CreateChannel, Either<BaseError, CreateChannelResult>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public CreateChannelHandler(IDbContextFactory<TvContext> dbContextFactory) => _dbContextFactory = dbContextFactory;
public async Task<Either<BaseError, CreateChannelResult>> Handle(
CreateChannel request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
return await validation.Apply(c => PersistChannel(dbContext, c));
}
private static async Task<CreateChannelResult> PersistChannel(TvContext dbContext, Channel channel)
private async Task<CreateChannelResult> PersistChannel(TvContext dbContext, Channel channel)
{
await dbContext.Channels.AddAsync(channel);
await dbContext.SaveChangesAsync();
searchTargets.SearchTargetsChanged();
await workerChannel.WriteAsync(new RefreshChannelList());
return new CreateChannelResult(channel.Id);
}

View File

@@ -1,6 +1,7 @@
using System.Threading.Channels;
using ErsatzTV.Core;
using ErsatzTV.Core.Interfaces.Metadata;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@@ -12,24 +13,26 @@ public class DeleteChannelHandler : IRequestHandler<DeleteChannel, Either<BaseEr
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ILocalFileSystem _localFileSystem;
private readonly ISearchTargets _searchTargets;
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
public DeleteChannelHandler(
ChannelWriter<IBackgroundServiceRequest> workerChannel,
IDbContextFactory<TvContext> dbContextFactory,
ILocalFileSystem localFileSystem)
ILocalFileSystem localFileSystem,
ISearchTargets searchTargets)
{
_workerChannel = workerChannel;
_dbContextFactory = dbContextFactory;
_localFileSystem = localFileSystem;
_searchTargets = searchTargets;
}
public async Task<Either<BaseError, Unit>> Handle(DeleteChannel request, CancellationToken cancellationToken)
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Channel> validation = await ChannelMustExist(dbContext, request);
return await LanguageExtensions.Apply(validation, c => DoDeletion(dbContext, c, cancellationToken));
return await validation.Apply(c => DoDeletion(dbContext, c, cancellationToken));
}
private async Task<Unit> DoDeletion(TvContext dbContext, Channel channel, CancellationToken cancellationToken)
@@ -37,6 +40,8 @@ public class DeleteChannelHandler : IRequestHandler<DeleteChannel, Either<BaseEr
dbContext.Channels.Remove(channel);
await dbContext.SaveChangesAsync(cancellationToken);
_searchTargets.SearchTargetsChanged();
// delete channel data from channel guide cache
string cacheFile = Path.Combine(FileSystemLayout.ChannelGuideCacheFolder, $"{channel.Number}.xml");
if (_localFileSystem.FileExists(cacheFile))

View File

@@ -5,7 +5,11 @@ using ErsatzTV.Core;
using ErsatzTV.Core.Interfaces.Metadata;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.IO;
using Scriban;
using Scriban.Runtime;
using WebMarkupMin.Core;
namespace ErsatzTV.Application.Channels;
@@ -13,16 +17,19 @@ public class RefreshChannelListHandler : IRequestHandler<RefreshChannelList>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ILocalFileSystem _localFileSystem;
private readonly ILogger<RefreshChannelListHandler> _logger;
private readonly RecyclableMemoryStreamManager _recyclableMemoryStreamManager;
public RefreshChannelListHandler(
RecyclableMemoryStreamManager recyclableMemoryStreamManager,
IDbContextFactory<TvContext> dbContextFactory,
ILocalFileSystem localFileSystem)
ILocalFileSystem localFileSystem,
ILogger<RefreshChannelListHandler> logger)
{
_recyclableMemoryStreamManager = recyclableMemoryStreamManager;
_dbContextFactory = dbContextFactory;
_localFileSystem = localFileSystem;
_logger = logger;
}
public async Task Handle(RefreshChannelList request, CancellationToken cancellationToken)
@@ -31,41 +38,60 @@ public class RefreshChannelListHandler : IRequestHandler<RefreshChannelList>
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
using MemoryStream ms = _recyclableMemoryStreamManager.GetStream();
string templateFileName = Path.Combine(FileSystemLayout.ChannelGuideTemplatesFolder, "channel.sbntxt");
// fall back to default template
if (!_localFileSystem.FileExists(templateFileName))
{
templateFileName = Path.Combine(FileSystemLayout.ChannelGuideTemplatesFolder, "_channel.sbntxt");
}
// fail if file doesn't exist
if (!_localFileSystem.FileExists(templateFileName))
{
_logger.LogError(
"Unable to generate channel list without template file {File}; please restart ErsatzTV",
templateFileName);
return;
}
var minifier = new XmlMinifier(
new XmlMinificationSettings
{
MinifyWhitespace = true,
RemoveXmlComments = true,
CollapseTagsWithoutContent = true
});
string text = await File.ReadAllTextAsync(templateFileName, cancellationToken);
var template = Template.Parse(text, templateFileName);
var templateContext = new XmlTemplateContext();
await using RecyclableMemoryStream ms = _recyclableMemoryStreamManager.GetStream();
await using var xml = XmlWriter.Create(
ms,
new XmlWriterSettings { Async = true, ConformanceLevel = ConformanceLevel.Fragment });
await foreach (ChannelResult channel in GetChannels(dbContext).WithCancellation(cancellationToken))
{
await xml.WriteStartElementAsync(null, "channel", null);
await xml.WriteAttributeStringAsync(null, "id", null, $"{channel.Number}.etv");
await xml.WriteStartElementAsync(null, "display-name", null);
await xml.WriteStringAsync($"{channel.Number} {channel.Name}");
await xml.WriteEndElementAsync(); // display-name (number and name)
await xml.WriteStartElementAsync(null, "display-name", null);
await xml.WriteStringAsync(channel.Number);
await xml.WriteEndElementAsync(); // display-name (number)
await xml.WriteStartElementAsync(null, "display-name", null);
await xml.WriteStringAsync(channel.Name);
await xml.WriteEndElementAsync(); // display-name (name)
foreach (string category in GetCategories(channel.Categories))
var data = new
{
await xml.WriteStartElementAsync(null, "category", null);
await xml.WriteAttributeStringAsync(null, "lang", null, "en");
await xml.WriteStringAsync(category);
await xml.WriteEndElementAsync(); // category
}
ChannelNumber = channel.Number,
ChannelName = channel.Name,
ChannelCategories = GetCategories(channel.Categories),
ChannelHasArtwork = !string.IsNullOrWhiteSpace(channel.ArtworkPath),
ChannelArtworkPath = channel.ArtworkPath
};
await xml.WriteStartElementAsync(null, "icon", null);
await xml.WriteAttributeStringAsync(null, "src", null, GetIconUrl(channel));
await xml.WriteEndElementAsync(); // icon
var scriptObject = new ScriptObject();
scriptObject.Import(data);
templateContext.PushGlobal(scriptObject);
await xml.WriteEndElementAsync(); // channel
string result = await template.RenderAsync(templateContext);
MarkupMinificationResult minified = minifier.Minify(result);
await xml.WriteRawAsync(minified.MinifiedContent);
}
await xml.FlushAsync();
@@ -106,11 +132,6 @@ public class RefreshChannelListHandler : IRequestHandler<RefreshChannelList>
.Distinct()
.ToList();
private static string GetIconUrl(ChannelResult channel) =>
string.IsNullOrWhiteSpace(channel.ArtworkPath)
? "{RequestBase}/iptv/images/ersatztv-500.png{AccessTokenUri}"
: $"{{RequestBase}}/iptv/logos/{channel.ArtworkPath}.jpg{{AccessTokenUri}}";
// ReSharper disable once ClassNeverInstantiated.Local
private sealed record ChannelResult(string Number, string Name, string Categories, string ArtworkPath);
}

View File

@@ -3,8 +3,7 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.Channels;
public record UpdateChannel
(
public record UpdateChannel(
int ChannelId,
string Name,
string Number,

View File

@@ -4,6 +4,7 @@ using System.Threading.Channels;
using ErsatzTV.Application.Subtitles;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@@ -12,26 +13,19 @@ using Channel = ErsatzTV.Core.Domain.Channel;
namespace ErsatzTV.Application.Channels;
public class UpdateChannelHandler : IRequestHandler<UpdateChannel, Either<BaseError, ChannelViewModel>>
public class UpdateChannelHandler(
ChannelWriter<IBackgroundServiceRequest> workerChannel,
IDbContextFactory<TvContext> dbContextFactory,
ISearchTargets searchTargets)
: IRequestHandler<UpdateChannel, Either<BaseError, ChannelViewModel>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
public UpdateChannelHandler(
ChannelWriter<IBackgroundServiceRequest> workerChannel,
IDbContextFactory<TvContext> dbContextFactory)
{
_workerChannel = workerChannel;
_dbContextFactory = dbContextFactory;
}
public async Task<Either<BaseError, ChannelViewModel>> Handle(
UpdateChannel request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
return await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request));
return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request));
}
private async Task<ChannelViewModel> ApplyUpdateRequest(TvContext dbContext, Channel c, UpdateChannel update)
@@ -78,6 +72,8 @@ public class UpdateChannelHandler : IRequestHandler<UpdateChannel, Either<BaseEr
c.FallbackFillerId = update.FallbackFillerId;
await dbContext.SaveChangesAsync();
searchTargets.SearchTargetsChanged();
if (c.SubtitleMode != ChannelSubtitleMode.None)
{
Option<Playout> maybePlayout = await dbContext.Playouts
@@ -85,10 +81,12 @@ public class UpdateChannelHandler : IRequestHandler<UpdateChannel, Either<BaseEr
foreach (Playout playout in maybePlayout)
{
await _workerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
await workerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
}
}
await workerChannel.WriteAsync(new RefreshChannelList());
return ProjectToViewModel(c);
}

View File

@@ -34,6 +34,9 @@ internal static class Mapper
channel.PreferredAudioLanguageCode,
GetStreamingMode(channel));
internal static ResolutionViewModel ProjectToViewModel(Resolution resolution) =>
new(resolution.Height, resolution.Width);
private static string GetLogo(Channel channel) =>
Optional(channel.Artwork.FirstOrDefault(a => a.ArtworkKind == ArtworkKind.Logo))
.Match(a => a.Path, string.Empty);
@@ -45,6 +48,7 @@ internal static class Mapper
StreamingMode.TransportStreamHybrid => "MPEG-TS",
StreamingMode.HttpLiveStreamingDirect => "HLS Direct",
StreamingMode.HttpLiveStreamingSegmenter => "HLS Segmenter",
StreamingMode.HttpLiveStreamingSegmenterV2 => "HLS Segmenter V2",
_ => throw new ArgumentOutOfRangeException(nameof(channel))
};
}

View File

@@ -86,7 +86,7 @@ public class GetChannelFramerateHandler : IRequestHandler<GetChannelFramerate, O
return result;
}
if (distinct.Any())
if (distinct.Count != 0)
{
_logger.LogInformation(
"All content on channel {ChannelNumber} has the same frame rate of {FrameRate}; will not normalize",

View File

@@ -3,5 +3,5 @@ using ErsatzTV.Core.Iptv;
namespace ErsatzTV.Application.Channels;
public record GetChannelGuide
(string Scheme, string Host, string BaseUrl, string AccessToken) : IRequest<Either<BaseError, ChannelGuide>>;
public record GetChannelGuide(string Scheme, string Host, string BaseUrl, string AccessToken)
: IRequest<Either<BaseError, ChannelGuide>>;

View File

@@ -2,5 +2,10 @@ using ErsatzTV.Core.Iptv;
namespace ErsatzTV.Application.Channels;
public record GetChannelPlaylist
(string Scheme, string Host, string BaseUrl, string Mode, string AccessToken) : IRequest<ChannelPlaylist>;
public record GetChannelPlaylist(
string Scheme,
string Host,
string BaseUrl,
string Mode,
string UserAgent,
string AccessToken) : IRequest<ChannelPlaylist>;

View File

@@ -20,6 +20,7 @@ public class GetChannelPlaylistHandler : IRequestHandler<GetChannelPlaylist, Cha
request.Host,
request.BaseUrl,
channels,
request.UserAgent,
request.AccessToken));
private static List<Channel> EnsureMode(IEnumerable<Channel> channels, string mode)
@@ -33,6 +34,10 @@ public class GetChannelPlaylistHandler : IRequestHandler<GetChannelPlaylist, Cha
channel.StreamingMode = StreamingMode.HttpLiveStreamingSegmenter;
result.Add(channel);
break;
case "segmenter-v2":
channel.StreamingMode = StreamingMode.HttpLiveStreamingSegmenterV2;
result.Add(channel);
break;
case "hls-direct":
channel.StreamingMode = StreamingMode.HttpLiveStreamingDirect;
result.Add(channel);

View File

@@ -0,0 +1,3 @@
namespace ErsatzTV.Application.Channels;
public record GetChannelResolution(string ChannelNumber) : IRequest<Option<ResolutionViewModel>>;

View File

@@ -0,0 +1,25 @@
using ErsatzTV.Core.Domain;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Channels;
public class GetChannelResolutionHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetChannelResolution, Option<ResolutionViewModel>>
{
public async Task<Option<ResolutionViewModel>> Handle(
GetChannelResolution request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
Option<Channel> maybeChannel = await dbContext.Channels
.AsNoTracking()
.Include(c => c.FFmpegProfile)
.ThenInclude(ff => ff.Resolution)
.SelectOneAsync(c => c.Number, c => c.Number == request.ChannelNumber);
return maybeChannel.Map(c => Mapper.ProjectToViewModel(c.FFmpegProfile.Resolution));
}
}

View File

@@ -0,0 +1,3 @@
namespace ErsatzTV.Application.Channels;
public record ResolutionViewModel(int Height, int Width);

View File

@@ -0,0 +1,14 @@
using System.Net;
using Scriban;
using Scriban.Parsing;
namespace ErsatzTV.Application.Channels;
public class XmlTemplateContext : TemplateContext
{
public override TemplateContext Write(SourceSpan span, object textAsObject)
=> base.Write(span, textAsObject is string text ? WebUtility.HtmlEncode(text) : textAsObject);
public override ValueTask<TemplateContext> WriteAsync(SourceSpan span, object textAsObject)
=> base.WriteAsync(span, textAsObject is string text ? WebUtility.HtmlEncode(text) : textAsObject);
}

View File

@@ -1,20 +1,19 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using Serilog.Core;
namespace ErsatzTV.Application.Configuration;
public class UpdateGeneralSettingsHandler : IRequestHandler<UpdateGeneralSettings, Either<BaseError, Unit>>
{
private readonly IConfigElementRepository _configElementRepository;
private readonly LoggingLevelSwitch _loggingLevelSwitch;
private readonly LoggingLevelSwitches _loggingLevelSwitches;
public UpdateGeneralSettingsHandler(
LoggingLevelSwitch loggingLevelSwitch,
LoggingLevelSwitches loggingLevelSwitches,
IConfigElementRepository configElementRepository)
{
_loggingLevelSwitch = loggingLevelSwitch;
_loggingLevelSwitches = loggingLevelSwitches;
_configElementRepository = configElementRepository;
}
@@ -24,8 +23,28 @@ public class UpdateGeneralSettingsHandler : IRequestHandler<UpdateGeneralSetting
private async Task<Unit> ApplyUpdate(GeneralSettingsViewModel generalSettings)
{
await _configElementRepository.Upsert(ConfigElementKey.MinimumLogLevel, generalSettings.MinimumLogLevel);
_loggingLevelSwitch.MinimumLevel = generalSettings.MinimumLogLevel;
await _configElementRepository.Upsert(ConfigElementKey.MinimumLogLevel, generalSettings.DefaultMinimumLogLevel);
_loggingLevelSwitches.DefaultLevelSwitch.MinimumLevel = generalSettings.DefaultMinimumLogLevel;
await _configElementRepository.Upsert(
ConfigElementKey.MinimumLogLevelScanning,
generalSettings.ScanningMinimumLogLevel);
_loggingLevelSwitches.ScanningLevelSwitch.MinimumLevel = generalSettings.ScanningMinimumLogLevel;
await _configElementRepository.Upsert(
ConfigElementKey.MinimumLogLevelScheduling,
generalSettings.SchedulingMinimumLogLevel);
_loggingLevelSwitches.SchedulingLevelSwitch.MinimumLevel = generalSettings.SchedulingMinimumLogLevel;
await _configElementRepository.Upsert(
ConfigElementKey.MinimumLogLevelStreaming,
generalSettings.StreamingMinimumLogLevel);
_loggingLevelSwitches.StreamingLevelSwitch.MinimumLevel = generalSettings.StreamingMinimumLogLevel;
await _configElementRepository.Upsert(
ConfigElementKey.MinimumLogLevelHttp,
generalSettings.HttpMinimumLogLevel);
_loggingLevelSwitches.HttpLevelSwitch.MinimumLevel = generalSettings.HttpMinimumLogLevel;
return Unit.Default;
}

View File

@@ -0,0 +1,5 @@
using ErsatzTV.Core;
namespace ErsatzTV.Application.Configuration;
public record UpdateXmltvSettings(XmltvSettingsViewModel XmltvSettings) : IRequest<Either<BaseError, Unit>>;

View File

@@ -0,0 +1,49 @@
using System.Threading.Channels;
using ErsatzTV.Application.Channels;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Configuration;
public class UpdateXmltvSettingsHandler(
IDbContextFactory<TvContext> dbContextFactory,
IConfigElementRepository configElementRepository,
ChannelWriter<IBackgroundServiceRequest> workerChannel)
: IRequestHandler<UpdateXmltvSettings, Either<BaseError, Unit>>
{
public async Task<Either<BaseError, Unit>> Handle(
UpdateXmltvSettings request,
CancellationToken cancellationToken)
{
int playoutDaysToBuild =
await configElementRepository
.GetValue<int>(ConfigElementKey.PlayoutDaysToBuild)
.IfNoneAsync(2);
if (playoutDaysToBuild < request.XmltvSettings.DaysToBuild)
{
return BaseError.New(
$"XMLTV days to build ({request.XmltvSettings.DaysToBuild}) cannot be greater than Playout days to build ({playoutDaysToBuild})");
}
return await ApplyUpdate(request.XmltvSettings);
}
private async Task<Unit> ApplyUpdate(XmltvSettingsViewModel xmltvSettings)
{
await configElementRepository.Upsert(ConfigElementKey.XmltvTimeZone, xmltvSettings.TimeZone);
await configElementRepository.Upsert(ConfigElementKey.XmltvDaysToBuild, xmltvSettings.DaysToBuild);
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync();
foreach (string channelNumber in await dbContext.Channels.Map(c => c.Number).ToListAsync())
{
await workerChannel.WriteAsync(new RefreshChannelData(channelNumber));
}
return Unit.Default;
}
}

View File

@@ -4,5 +4,9 @@ namespace ErsatzTV.Application.Configuration;
public class GeneralSettingsViewModel
{
public LogEventLevel MinimumLogLevel { get; set; }
public LogEventLevel DefaultMinimumLogLevel { get; set; }
public LogEventLevel ScanningMinimumLogLevel { get; set; }
public LogEventLevel SchedulingMinimumLogLevel { get; set; }
public LogEventLevel StreamingMinimumLogLevel { get; set; }
public LogEventLevel HttpMinimumLogLevel { get; set; }
}

View File

@@ -13,12 +13,28 @@ public class GetGeneralSettingsHandler : IRequestHandler<GetGeneralSettings, Gen
public async Task<GeneralSettingsViewModel> Handle(GetGeneralSettings request, CancellationToken cancellationToken)
{
Option<LogEventLevel> maybeLogLevel =
Option<LogEventLevel> maybeDefaultLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevel);
Option<LogEventLevel> maybeScanningLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelScanning);
Option<LogEventLevel> maybeSchedulingLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelScheduling);
Option<LogEventLevel> maybeStreamingLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelStreaming);
Option<LogEventLevel> maybeHttpLevel =
await _configElementRepository.GetValue<LogEventLevel>(ConfigElementKey.MinimumLogLevelHttp);
return new GeneralSettingsViewModel
{
MinimumLogLevel = await maybeLogLevel.IfNoneAsync(LogEventLevel.Information)
DefaultMinimumLogLevel = await maybeDefaultLevel.IfNoneAsync(LogEventLevel.Information),
ScanningMinimumLogLevel = await maybeScanningLevel.IfNoneAsync(LogEventLevel.Information),
SchedulingMinimumLogLevel = await maybeSchedulingLevel.IfNoneAsync(LogEventLevel.Information),
StreamingMinimumLogLevel = await maybeStreamingLevel.IfNoneAsync(LogEventLevel.Information),
HttpMinimumLogLevel = await maybeHttpLevel.IfNoneAsync(LogEventLevel.Information)
};
}
}

View File

@@ -0,0 +1,3 @@
namespace ErsatzTV.Application.Configuration;
public record GetXmltvSettings : IRequest<XmltvSettingsViewModel>;

View File

@@ -0,0 +1,22 @@
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Configuration;
public class GetXmltvSettingsHandler(IConfigElementRepository configElementRepository)
: IRequestHandler<GetXmltvSettings, XmltvSettingsViewModel>
{
public async Task<XmltvSettingsViewModel> Handle(GetXmltvSettings request, CancellationToken cancellationToken)
{
Option<int> daysToBuild = await configElementRepository.GetValue<int>(ConfigElementKey.XmltvDaysToBuild);
Option<XmltvTimeZone> maybeTimeZone =
await configElementRepository.GetValue<XmltvTimeZone>(ConfigElementKey.XmltvTimeZone);
return new XmltvSettingsViewModel
{
DaysToBuild = await daysToBuild.IfNoneAsync(2),
TimeZone = await maybeTimeZone.IfNoneAsync(XmltvTimeZone.Local)
};
}
}

View File

@@ -0,0 +1,7 @@
namespace ErsatzTV.Application.Configuration;
public class XmltvSettingsViewModel
{
public int DaysToBuild { get; set; }
public XmltvTimeZone TimeZone { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace ErsatzTV.Application.Configuration;
public enum XmltvTimeZone
{
Local = 0,
Utc = 1
}

View File

@@ -92,7 +92,7 @@ public class SynchronizeEmbyLibrariesHandler : IRequestHandler<SynchronizeEmbyLi
toAdd,
toRemove,
toUpdate);
if (ids.Any())
if (ids.Count != 0)
{
await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();

View File

@@ -2,7 +2,6 @@
namespace ErsatzTV.Application.Emby;
public record UpdateEmbyLibraryPreferences
(List<EmbyLibraryPreference> Preferences) : IRequest<Either<BaseError, Unit>>;
public record UpdateEmbyLibraryPreferences(List<EmbyLibraryPreference> Preferences) : IRequest<Either<BaseError, Unit>>;
public record EmbyLibraryPreference(int Id, bool ShouldSyncItems);

View File

@@ -6,7 +6,7 @@ namespace ErsatzTV.Application.Emby;
public class
UpdateEmbyLibraryPreferencesHandler : IRequestHandler<UpdateEmbyLibraryPreferences,
Either<BaseError, Unit>>
Either<BaseError, Unit>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;
private readonly ISearchIndex _searchIndex;

View File

@@ -4,9 +4,9 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.Emby;
public record EmbyLibraryViewModel(
int Id,
string Name,
LibraryMediaKind MediaKind,
bool ShouldSyncItems,
int MediaSourceId)
int Id,
string Name,
LibraryMediaKind MediaKind,
bool ShouldSyncItems,
int MediaSourceId)
: LibraryViewModel("Emby", Id, Name, MediaKind, MediaSourceId, string.Empty);

View File

@@ -1,4 +1,3 @@
namespace ErsatzTV.Application.Emby;
public record GetEmbyPathReplacementsBySourceId
(int EmbyMediaSourceId) : IRequest<List<EmbyPathReplacementViewModel>>;
public record GetEmbyPathReplacementsBySourceId(int EmbyMediaSourceId) : IRequest<List<EmbyPathReplacementViewModel>>;

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<NoWarn>VSTHRD200</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<AnalysisLevel>latest-Recommended</AnalysisLevel>
@@ -10,17 +10,19 @@
<ItemGroup>
<PackageReference Include="Bugsnag" Version="3.1.0" />
<PackageReference Include="CliWrap" Version="3.6.4" />
<PackageReference Include="CliWrap" Version="3.6.6" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.7.30">
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.Formatting.Compact.Reader" Version="2.0.0" />
<PackageReference Include="Winista.MimeDetect" Version="1.0.1" />
<PackageReference Include="Serilog.Formatting.Compact.Reader" Version="3.0.0" />
<PackageReference Include="WebMarkupMin.Core" Version="2.16.0" />
<PackageReference Include="Winista.MimeDetect" Version="1.1.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -35,6 +35,8 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=programschedules_005Cqueries/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=resolutions_005Ccommands/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=resolutions_005Cqueries/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=scheduling_005Ccommands/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=scheduling_005Cqueries/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=search_005Ccommands/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=search_005Cqueries/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=streaming_005Ccommands/@EntryIndexedValue">True</s:Boolean>

View File

@@ -2,5 +2,4 @@
namespace ErsatzTV.Application.FFmpegProfiles;
public record CopyFFmpegProfile
(int FFmpegProfileId, string Name) : IRequest<Either<BaseError, FFmpegProfileViewModel>>;
public record CopyFFmpegProfile(int FFmpegProfileId, string Name) : IRequest<Either<BaseError, FFmpegProfileViewModel>>;

View File

@@ -1,5 +1,7 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.Core.Interfaces.Search;
using static ErsatzTV.Application.FFmpegProfiles.Mapper;
namespace ErsatzTV.Application.FFmpegProfiles;
@@ -8,9 +10,13 @@ public class
CopyFFmpegProfileHandler : IRequestHandler<CopyFFmpegProfile, Either<BaseError, FFmpegProfileViewModel>>
{
private readonly IFFmpegProfileRepository _ffmpegProfileRepository;
private readonly ISearchTargets _searchTargets;
public CopyFFmpegProfileHandler(IFFmpegProfileRepository ffmpegProfileRepository) =>
public CopyFFmpegProfileHandler(IFFmpegProfileRepository ffmpegProfileRepository, ISearchTargets searchTargets)
{
_ffmpegProfileRepository = ffmpegProfileRepository;
_searchTargets = searchTargets;
}
public Task<Either<BaseError, FFmpegProfileViewModel>> Handle(
CopyFFmpegProfile request,
@@ -19,9 +25,12 @@ public class
.MapT(PerformCopy)
.Bind(v => v.ToEitherAsync());
private Task<FFmpegProfileViewModel> PerformCopy(CopyFFmpegProfile request) =>
_ffmpegProfileRepository.Copy(request.FFmpegProfileId, request.Name)
.Map(ProjectToViewModel);
private async Task<FFmpegProfileViewModel> PerformCopy(CopyFFmpegProfile request)
{
FFmpegProfile copy = await _ffmpegProfileRepository.Copy(request.FFmpegProfileId, request.Name);
_searchTargets.SearchTargetsChanged();
return ProjectToViewModel(copy);
}
private static Task<Validation<BaseError, CopyFFmpegProfile>> Validate(CopyFFmpegProfile request) =>
ValidateName(request).AsTask().MapT(_ => request);

View File

@@ -12,14 +12,18 @@ public record CreateFFmpegProfile(
string VaapiDevice,
int? QsvExtraHardwareFrames,
int ResolutionId,
ScalingBehavior ScalingBehavior,
FFmpegProfileVideoFormat VideoFormat,
string VideoProfile,
string VideoPreset,
bool AllowBFrames,
FFmpegProfileBitDepth BitDepth,
int VideoBitrate,
int VideoBufferSize,
FFmpegProfileAudioFormat AudioFormat,
int AudioBitrate,
int AudioBufferSize,
bool NormalizeLoudness,
NormalizeLoudnessMode NormalizeLoudnessMode,
int AudioChannels,
int AudioSampleRate,
bool NormalizeFramerate,

View File

@@ -1,5 +1,6 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@@ -10,9 +11,13 @@ public class CreateFFmpegProfileHandler :
IRequestHandler<CreateFFmpegProfile, Either<BaseError, CreateFFmpegProfileResult>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ISearchTargets _searchTargets;
public CreateFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory) =>
public CreateFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory, ISearchTargets searchTargets)
{
_dbContextFactory = dbContextFactory;
_searchTargets = searchTargets;
}
public async Task<Either<BaseError, CreateFFmpegProfileResult>> Handle(
CreateFFmpegProfile request,
@@ -23,12 +28,13 @@ public class CreateFFmpegProfileHandler :
return await validation.Apply(profile => PersistFFmpegProfile(dbContext, profile));
}
private static async Task<CreateFFmpegProfileResult> PersistFFmpegProfile(
private async Task<CreateFFmpegProfileResult> PersistFFmpegProfile(
TvContext dbContext,
FFmpegProfile ffmpegProfile)
{
await dbContext.FFmpegProfiles.AddAsync(ffmpegProfile);
await dbContext.SaveChangesAsync();
_searchTargets.SearchTargetsChanged();
return new CreateFFmpegProfileResult(ffmpegProfile.Id);
}
@@ -46,14 +52,18 @@ public class CreateFFmpegProfileHandler :
VaapiDevice = request.VaapiDevice,
QsvExtraHardwareFrames = request.QsvExtraHardwareFrames,
ResolutionId = resolutionId,
ScalingBehavior = request.ScalingBehavior,
VideoFormat = request.VideoFormat,
VideoProfile = request.VideoProfile,
VideoPreset = request.VideoPreset,
AllowBFrames = request.AllowBFrames,
BitDepth = request.BitDepth,
VideoBitrate = request.VideoBitrate,
VideoBufferSize = request.VideoBufferSize,
AudioFormat = request.AudioFormat,
AudioBitrate = request.AudioBitrate,
AudioBufferSize = request.AudioBufferSize,
NormalizeLoudness = request.NormalizeLoudness,
NormalizeLoudnessMode = request.NormalizeLoudnessMode,
AudioChannels = request.AudioChannels,
AudioSampleRate = request.AudioSampleRate,
NormalizeFramerate = request.NormalizeFramerate,

View File

@@ -1,5 +1,6 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@@ -9,23 +10,28 @@ namespace ErsatzTV.Application.FFmpegProfiles;
public class DeleteFFmpegProfileHandler : IRequestHandler<DeleteFFmpegProfile, Either<BaseError, Unit>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ISearchTargets _searchTargets;
public DeleteFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory) =>
public DeleteFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory, ISearchTargets searchTargets)
{
_dbContextFactory = dbContextFactory;
_searchTargets = searchTargets;
}
public async Task<Either<BaseError, Unit>> Handle(
DeleteFFmpegProfile request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, FFmpegProfile> validation = await FFmpegProfileMustExist(dbContext, request);
return await validation.Apply(p => DoDeletion(dbContext, p));
}
private static async Task<Unit> DoDeletion(TvContext dbContext, FFmpegProfile ffmpegProfile)
private async Task<Unit> DoDeletion(TvContext dbContext, FFmpegProfile ffmpegProfile)
{
dbContext.FFmpegProfiles.Remove(ffmpegProfile);
await dbContext.SaveChangesAsync();
_searchTargets.SearchTargetsChanged();
return Unit.Default;
}

View File

@@ -13,14 +13,18 @@ public record UpdateFFmpegProfile(
string VaapiDevice,
int? QsvExtraHardwareFrames,
int ResolutionId,
ScalingBehavior ScalingBehavior,
FFmpegProfileVideoFormat VideoFormat,
string VideoProfile,
string VideoPreset,
bool AllowBFrames,
FFmpegProfileBitDepth BitDepth,
int VideoBitrate,
int VideoBufferSize,
FFmpegProfileAudioFormat AudioFormat,
int AudioBitrate,
int AudioBufferSize,
bool NormalizeLoudness,
NormalizeLoudnessMode NormalizeLoudnessMode,
int AudioChannels,
int AudioSampleRate,
bool NormalizeFramerate,

View File

@@ -1,5 +1,6 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@@ -10,9 +11,13 @@ public class
UpdateFFmpegProfileHandler : IRequestHandler<UpdateFFmpegProfile, Either<BaseError, UpdateFFmpegProfileResult>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ISearchTargets _searchTargets;
public UpdateFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory) =>
public UpdateFFmpegProfileHandler(IDbContextFactory<TvContext> dbContextFactory, ISearchTargets searchTargets)
{
_dbContextFactory = dbContextFactory;
_searchTargets = searchTargets;
}
public async Task<Either<BaseError, UpdateFFmpegProfileResult>> Handle(
UpdateFFmpegProfile request,
@@ -23,7 +28,7 @@ public class
return await validation.Apply(p => ApplyUpdateRequest(dbContext, p, request));
}
private static async Task<UpdateFFmpegProfileResult> ApplyUpdateRequest(
private async Task<UpdateFFmpegProfileResult> ApplyUpdateRequest(
TvContext dbContext,
FFmpegProfile p,
UpdateFFmpegProfile update)
@@ -35,7 +40,11 @@ public class
p.VaapiDevice = update.VaapiDevice;
p.QsvExtraHardwareFrames = update.QsvExtraHardwareFrames;
p.ResolutionId = update.ResolutionId;
p.ScalingBehavior = update.ScalingBehavior;
p.VideoFormat = update.VideoFormat;
p.VideoProfile = update.VideoProfile;
p.VideoPreset = update.VideoPreset;
p.AllowBFrames = update.AllowBFrames;
// mpeg2video only supports 8-bit content
p.BitDepth = update.VideoFormat == FFmpegProfileVideoFormat.Mpeg2Video
@@ -47,12 +56,15 @@ public class
p.AudioFormat = update.AudioFormat;
p.AudioBitrate = update.AudioBitrate;
p.AudioBufferSize = update.AudioBufferSize;
p.NormalizeLoudness = update.NormalizeLoudness;
p.NormalizeLoudnessMode = update.NormalizeLoudnessMode;
p.AudioChannels = update.AudioChannels;
p.AudioSampleRate = update.AudioSampleRate;
p.NormalizeFramerate = update.NormalizeFramerate;
p.DeinterlaceVideo = update.DeinterlaceVideo;
await dbContext.SaveChangesAsync();
_searchTargets.SearchTargetsChanged();
return new UpdateFFmpegProfileResult(p.Id);
}

View File

@@ -1,5 +1,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Threading.Channels;
using ErsatzTV.Application.Subtitles;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Metadata;
@@ -11,13 +13,16 @@ public class UpdateFFmpegSettingsHandler : IRequestHandler<UpdateFFmpegSettings,
{
private readonly IConfigElementRepository _configElementRepository;
private readonly ILocalFileSystem _localFileSystem;
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
public UpdateFFmpegSettingsHandler(
IConfigElementRepository configElementRepository,
ILocalFileSystem localFileSystem)
ILocalFileSystem localFileSystem,
ChannelWriter<IBackgroundServiceRequest> workerChannel)
{
_configElementRepository = configElementRepository;
_localFileSystem = localFileSystem;
_workerChannel = workerChannel;
}
public Task<Either<BaseError, Unit>> Handle(
@@ -87,6 +92,26 @@ public class UpdateFFmpegSettingsHandler : IRequestHandler<UpdateFFmpegSettings,
ConfigElementKey.FFmpegPreferredLanguageCode,
request.Settings.PreferredAudioLanguageCode);
await _configElementRepository.Upsert(
ConfigElementKey.FFmpegUseEmbeddedSubtitles,
request.Settings.UseEmbeddedSubtitles);
// do not extract when subtitles are not used
if (request.Settings.UseEmbeddedSubtitles == false)
{
request.Settings.ExtractEmbeddedSubtitles = false;
}
await _configElementRepository.Upsert(
ConfigElementKey.FFmpegExtractEmbeddedSubtitles,
request.Settings.ExtractEmbeddedSubtitles);
// queue extracting all embedded subtitles
if (request.Settings.ExtractEmbeddedSubtitles)
{
await _workerChannel.WriteAsync(new ExtractEmbeddedSubtitles(Option<int>.None));
}
if (request.Settings.GlobalWatermarkId is not null)
{
await _configElementRepository.Upsert(

View File

@@ -13,14 +13,18 @@ public record FFmpegProfileViewModel(
string VaapiDevice,
int? QsvExtraHardwareFrames,
ResolutionViewModel Resolution,
ScalingBehavior ScalingBehavior,
FFmpegProfileVideoFormat VideoFormat,
string VideoProfile,
string VideoPreset,
bool AllowBFrames,
FFmpegProfileBitDepth BitDepth,
int VideoBitrate,
int VideoBufferSize,
FFmpegProfileAudioFormat AudioFormat,
int AudioBitrate,
int AudioBufferSize,
bool NormalizeLoudness,
NormalizeLoudnessMode NormalizeLoudnessMode,
int AudioChannels,
int AudioSampleRate,
bool NormalizeFramerate,

View File

@@ -8,6 +8,8 @@ public class FFmpegSettingsViewModel
public string FFprobePath { get; set; }
public int DefaultFFmpegProfileId { get; set; }
public string PreferredAudioLanguageCode { get; set; }
public bool UseEmbeddedSubtitles { get; set; }
public bool ExtractEmbeddedSubtitles { get; set; }
public bool SaveReports { get; set; }
public int? GlobalWatermarkId { get; set; }
public int? GlobalFallbackFillerId { get; set; }

View File

@@ -15,14 +15,18 @@ internal static class Mapper
profile.VaapiDevice,
profile.QsvExtraHardwareFrames,
Resolutions.Mapper.ProjectToViewModel(profile.Resolution),
profile.ScalingBehavior,
profile.VideoFormat,
profile.VideoProfile,
profile.VideoPreset ?? string.Empty,
profile.AllowBFrames,
profile.BitDepth,
profile.VideoBitrate,
profile.VideoBufferSize,
profile.AudioFormat,
profile.AudioBitrate,
profile.AudioBufferSize,
profile.NormalizeLoudness,
profile.NormalizeLoudnessMode,
profile.AudioChannels,
profile.AudioSampleRate,
profile.NormalizeFramerate,
@@ -51,7 +55,7 @@ internal static class Mapper
(int)ffmpegProfile.AudioFormat,
ffmpegProfile.AudioBitrate,
ffmpegProfile.AudioBufferSize,
ffmpegProfile.NormalizeLoudness,
(int)ffmpegProfile.NormalizeLoudnessMode,
ffmpegProfile.AudioChannels,
ffmpegProfile.AudioSampleRate,
ffmpegProfile.NormalizeFramerate,

View File

@@ -8,7 +8,7 @@ namespace ErsatzTV.Application.FFmpegProfiles;
public class
GetFFmpegProfileByIdForApiHandler : IRequestHandler<GetFFmpegFullProfileByIdForApi,
Option<FFmpegFullProfileResponseModel>>
Option<FFmpegFullProfileResponseModel>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;

View File

@@ -23,6 +23,10 @@ public class GetFFmpegSettingsHandler : IRequestHandler<GetFFmpegSettings, FFmpe
await _configElementRepository.GetValue<bool>(ConfigElementKey.FFmpegSaveReports);
Option<string> preferredAudioLanguageCode =
await _configElementRepository.GetValue<string>(ConfigElementKey.FFmpegPreferredLanguageCode);
Option<bool> useEmbeddedSubtitles =
await _configElementRepository.GetValue<bool>(ConfigElementKey.FFmpegUseEmbeddedSubtitles);
Option<bool> extractEmbeddedSubtitles =
await _configElementRepository.GetValue<bool>(ConfigElementKey.FFmpegExtractEmbeddedSubtitles);
Option<int> watermark =
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegGlobalWatermarkId);
Option<int> fallbackFiller =
@@ -42,6 +46,8 @@ public class GetFFmpegSettingsHandler : IRequestHandler<GetFFmpegSettings, FFmpe
FFprobePath = await ffprobePath.IfNoneAsync(string.Empty),
DefaultFFmpegProfileId = await defaultFFmpegProfileId.IfNoneAsync(0),
SaveReports = await saveReports.IfNoneAsync(false),
UseEmbeddedSubtitles = await useEmbeddedSubtitles.IfNoneAsync(true),
ExtractEmbeddedSubtitles = await extractEmbeddedSubtitles.IfNoneAsync(false),
PreferredAudioLanguageCode = await preferredAudioLanguageCode.IfNoneAsync("eng"),
HlsSegmenterIdleTimeout = await hlsSegmenterIdleTimeout.IfNoneAsync(60),
WorkAheadSegmenterLimit = await workAheadSegmenterLimit.IfNoneAsync(1),

View File

@@ -0,0 +1,5 @@
using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.FFmpegProfiles;
public record GetSupportedHardwareAccelerationKinds : IRequest<List<HardwareAccelerationKind>>;

View File

@@ -0,0 +1,79 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.FFmpeg;
using ErsatzTV.FFmpeg.Capabilities;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.FFmpegProfiles;
public class
GetSupportedHardwareAccelerationKindsHandler : IRequestHandler<GetSupportedHardwareAccelerationKinds,
List<HardwareAccelerationKind>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IHardwareCapabilitiesFactory _hardwareCapabilitiesFactory;
public GetSupportedHardwareAccelerationKindsHandler(
IDbContextFactory<TvContext> dbContextFactory,
IHardwareCapabilitiesFactory hardwareCapabilitiesFactory)
{
_dbContextFactory = dbContextFactory;
_hardwareCapabilitiesFactory = hardwareCapabilitiesFactory;
}
public async Task<List<HardwareAccelerationKind>> Handle(
GetSupportedHardwareAccelerationKinds request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, string> validation = await Validate(dbContext);
return await validation.Match(
GetHardwareAccelerationKinds,
_ => Task.FromResult(new List<HardwareAccelerationKind> { HardwareAccelerationKind.None }));
}
private async Task<List<HardwareAccelerationKind>> GetHardwareAccelerationKinds(string ffmpegPath)
{
var result = new List<HardwareAccelerationKind> { HardwareAccelerationKind.None };
IFFmpegCapabilities ffmpegCapabilities = await _hardwareCapabilitiesFactory.GetFFmpegCapabilities(ffmpegPath);
if (ffmpegCapabilities.HasHardwareAcceleration(HardwareAccelerationMode.Nvenc))
{
result.Add(HardwareAccelerationKind.Nvenc);
}
if (ffmpegCapabilities.HasHardwareAcceleration(HardwareAccelerationMode.Qsv))
{
result.Add(HardwareAccelerationKind.Qsv);
}
if (ffmpegCapabilities.HasHardwareAcceleration(HardwareAccelerationMode.Vaapi))
{
result.Add(HardwareAccelerationKind.Vaapi);
}
if (ffmpegCapabilities.HasHardwareAcceleration(HardwareAccelerationMode.VideoToolbox))
{
result.Add(HardwareAccelerationKind.VideoToolbox);
}
if (ffmpegCapabilities.HasHardwareAcceleration(HardwareAccelerationMode.Amf))
{
result.Add(HardwareAccelerationKind.Amf);
}
return result;
}
private static async Task<Validation<BaseError, string>> Validate(TvContext dbContext) =>
await FFmpegPathMustExist(dbContext);
private static Task<Validation<BaseError, string>> FFmpegPathMustExist(TvContext dbContext) =>
dbContext.ConfigElements.GetValue<string>(ConfigElementKey.FFmpegPath)
.FilterT(File.Exists)
.Map(maybePath => maybePath.ToValidation<BaseError>("FFmpeg path does not exist on filesystem"));
}

View File

@@ -0,0 +1,3 @@
namespace ErsatzTV.Application.Images;
public record UpdateImageFolderDuration(int LibraryFolderId, double? ImageFolderDuration) : IRequest<double?>;

View File

@@ -0,0 +1,124 @@
using ErsatzTV.Core.Domain;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Images;
public class UpdateImageFolderDurationHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<UpdateImageFolderDuration, double?>
{
public async Task<double?> Handle(UpdateImageFolderDuration request, CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
if (request.ImageFolderDuration.IfNone(1) < 0.01)
{
request = request with { ImageFolderDuration = 0.01 };
}
// delete entry if null
if (request.ImageFolderDuration is null)
{
await dbContext.ImageFolderDurations
.Filter(ifd => ifd.LibraryFolderId == request.LibraryFolderId)
.ExecuteDeleteAsync(cancellationToken);
}
// upsert if non-null
else
{
Option<ImageFolderDuration> maybeExisting = await dbContext.ImageFolderDurations
.SelectOneAsync(ifd => ifd.LibraryFolderId, ifd => ifd.LibraryFolderId == request.LibraryFolderId);
if (maybeExisting.IsNone)
{
var entry = new ImageFolderDuration
{
LibraryFolderId = request.LibraryFolderId
};
maybeExisting = entry;
await dbContext.ImageFolderDurations.AddAsync(entry, cancellationToken);
}
foreach (ImageFolderDuration existing in maybeExisting)
{
existing.DurationSeconds = request.ImageFolderDuration.Value;
await dbContext.SaveChangesAsync(cancellationToken);
}
}
// update all images (bfs) starting at this folder
Option<LibraryFolder> maybeFolder = await dbContext.LibraryFolders
.AsNoTracking()
.Include(lf => lf.ImageFolderDuration)
.SelectOneAsync(lf => lf.Id, lf => lf.Id == request.LibraryFolderId);
var queue = new Queue<FolderWithParentDuration>();
foreach (LibraryFolder libraryFolder in maybeFolder)
{
LibraryFolder currentFolder = libraryFolder;
// walk up to get duration, if needed
double? durationSeconds = currentFolder.ImageFolderDuration?.DurationSeconds;
while (durationSeconds is null && currentFolder?.ParentId is not null)
{
Option<LibraryFolder> maybeParent = await dbContext.LibraryFolders
.AsNoTracking()
.Include(lf => lf.ImageFolderDuration)
.SelectOneAsync(lf => lf.Id, lf => lf.Id == currentFolder.ParentId);
if (maybeParent.IsNone)
{
currentFolder = null;
}
foreach (LibraryFolder parent in maybeParent)
{
currentFolder = parent;
durationSeconds = currentFolder.ImageFolderDuration?.DurationSeconds;
}
}
queue.Enqueue(new FolderWithParentDuration(libraryFolder, durationSeconds));
}
while (queue.Count > 0)
{
(LibraryFolder currentFolder, double? parentDuration) = queue.Dequeue();
double? effectiveDuration = currentFolder.ImageFolderDuration?.DurationSeconds ?? parentDuration;
// Serilog.Log.Logger.Information(
// "Updating folder {Id} with parent duration {ParentDuration}, effective duration {EffectiveDuration}",
// currentFolder.Id,
// parentDuration,
// effectiveDuration);
// update all images in this folder
await dbContext.ImageMetadata
.Filter(
im => im.Image.MediaVersions.Any(
mv => mv.MediaFiles.Any(mf => mf.LibraryFolderId == currentFolder.Id)))
.ExecuteUpdateAsync(
setters => setters.SetProperty(im => im.DurationSeconds, effectiveDuration),
cancellationToken);
List<LibraryFolder> children = await dbContext.LibraryFolders
.AsNoTracking()
.Filter(lf => lf.ParentId == currentFolder.Id)
.Include(lf => lf.ImageFolderDuration)
.ToListAsync(cancellationToken);
// queue all children
foreach (LibraryFolder child in children)
{
queue.Enqueue(new FolderWithParentDuration(child, effectiveDuration));
}
}
return request.ImageFolderDuration;
}
private sealed record FolderWithParentDuration(LibraryFolder LibraryFolder, double? ParentDuration);
}

View File

@@ -0,0 +1,9 @@
namespace ErsatzTV.Application.Images;
public record ImageFolderViewModel(
int LibraryFolderId,
string Name,
string FullPath,
int SubfolderCount,
int ImageCount,
Option<double> DurationSeconds);

View File

@@ -0,0 +1,18 @@
using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.Images;
public static class Mapper
{
public static ImageFolderViewModel ProjectToViewModel(
LibraryFolder libraryFolder,
int childCount,
int imageCount) =>
new(
libraryFolder.Id,
new DirectoryInfo(libraryFolder.Path).Name,
libraryFolder.Path,
childCount,
imageCount,
libraryFolder.ImageFolderDuration?.DurationSeconds ?? Option<double>.None);
}

View File

@@ -3,6 +3,5 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.Images;
public record GetCachedImagePath
(string FileName, ArtworkKind ArtworkKind, int? MaxHeight = null) : IRequest<
Either<BaseError, CachedImagePathViewModel>>;
public record GetCachedImagePath(string FileName, ArtworkKind ArtworkKind, int? MaxHeight = null) : IRequest<
Either<BaseError, CachedImagePathViewModel>>;

View File

@@ -0,0 +1,3 @@
namespace ErsatzTV.Application.Images;
public record GetImageFolders(Option<int> LibraryFolderId) : IRequest<List<ImageFolderViewModel>>;

View File

@@ -0,0 +1,49 @@
using ErsatzTV.Core.Domain;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Images;
public class GetImageFoldersHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetImageFolders, List<ImageFolderViewModel>>
{
public async Task<List<ImageFolderViewModel>> Handle(GetImageFolders request, CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
// default to returning top-level folders
int? parentId = null;
// if a specific folder is requested, return its children
foreach (int libraryFolderId in request.LibraryFolderId)
{
parentId = libraryFolderId;
}
List<LibraryFolder> folders = await dbContext.LibraryFolders
.AsNoTracking()
.Include(lf => lf.ImageFolderDuration)
.Filter(lf => lf.LibraryPath.Library.MediaKind == LibraryMediaKind.Images)
.Filter(lf => lf.ParentId == parentId)
.ToListAsync(cancellationToken);
var result = new List<ImageFolderViewModel>();
foreach (LibraryFolder folder in folders)
{
// count direct children of this folder
int childCount = await dbContext.LibraryFolders
.AsNoTracking()
.CountAsync(lf => lf.ParentId == folder.Id, cancellationToken);
// count all child images (any level)
int imageCount = await dbContext.MediaFiles
.AsNoTracking()
.CountAsync(mf => mf.Path.StartsWith(folder.Path), cancellationToken);
result.Add(Mapper.ProjectToViewModel(folder, childCount, imageCount));
}
return result;
}
}

View File

@@ -0,0 +1,85 @@
using System.Globalization;
using System.Threading.Channels;
using ErsatzTV.Application.Libraries;
using ErsatzTV.Core;
using ErsatzTV.Core.Errors;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.FFmpeg.Runtime;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Jellyfin;
public class CallJellyfinCollectionScannerHandler : CallLibraryScannerHandler<SynchronizeJellyfinCollections>,
IRequestHandler<SynchronizeJellyfinCollections, Either<BaseError, Unit>>
{
public CallJellyfinCollectionScannerHandler(
IDbContextFactory<TvContext> dbContextFactory,
IConfigElementRepository configElementRepository,
ChannelWriter<ISearchIndexBackgroundServiceRequest> channel,
IMediator mediator,
IRuntimeInfo runtimeInfo) : base(dbContextFactory, configElementRepository, channel, mediator, runtimeInfo)
{
}
public async Task<Either<BaseError, Unit>>
Handle(SynchronizeJellyfinCollections request, CancellationToken cancellationToken)
{
Validation<BaseError, string> validation = await Validate(request);
return await validation.Match(
scanner => PerformScan(scanner, request, cancellationToken),
error =>
{
foreach (ScanIsNotRequired scanIsNotRequired in error.OfType<ScanIsNotRequired>())
{
return Task.FromResult<Either<BaseError, Unit>>(scanIsNotRequired);
}
return Task.FromResult<Either<BaseError, Unit>>(error.Join());
});
}
protected override async Task<DateTimeOffset> GetLastScan(
TvContext dbContext,
SynchronizeJellyfinCollections request)
{
DateTime minDateTime = await dbContext.JellyfinMediaSources
.SelectOneAsync(l => l.Id, l => l.Id == request.JellyfinMediaSourceId)
.Match(l => l.LastCollectionsScan ?? SystemTime.MinValueUtc, () => SystemTime.MaxValueUtc);
return new DateTimeOffset(minDateTime, TimeSpan.Zero);
}
protected override bool ScanIsRequired(
DateTimeOffset lastScan,
int libraryRefreshInterval,
SynchronizeJellyfinCollections request)
{
if (lastScan == SystemTime.MaxValueUtc)
{
return false;
}
DateTimeOffset nextScan = lastScan + TimeSpan.FromHours(libraryRefreshInterval);
return request.ForceScan || libraryRefreshInterval > 0 && nextScan < DateTimeOffset.Now;
}
private async Task<Either<BaseError, Unit>> PerformScan(
string scanner,
SynchronizeJellyfinCollections request,
CancellationToken cancellationToken)
{
var arguments = new List<string>
{
"scan-jellyfin-collections", request.JellyfinMediaSourceId.ToString(CultureInfo.InvariantCulture)
};
if (request.ForceScan)
{
arguments.Add("--force");
}
return await base.PerformScan(scanner, arguments, cancellationToken).MapT(_ => Unit.Default);
}
}

View File

@@ -10,7 +10,7 @@ namespace ErsatzTV.Application.Jellyfin;
public class
SynchronizeJellyfinAdminUserIdHandler : IRequestHandler<SynchronizeJellyfinAdminUserId,
Either<BaseError, Unit>>
Either<BaseError, Unit>>
{
private readonly IJellyfinApiClient _jellyfinApiClient;
private readonly IJellyfinSecretStore _jellyfinSecretStore;

View File

@@ -0,0 +1,7 @@
using ErsatzTV.Core;
namespace ErsatzTV.Application.Jellyfin;
public record SynchronizeJellyfinCollections(int JellyfinMediaSourceId, bool ForceScan) :
IRequest<Either<BaseError, Unit>>,
IScannerBackgroundServiceRequest;

View File

@@ -94,7 +94,7 @@ public class
toAdd,
toRemove,
toUpdate);
if (ids.Any())
if (ids.Count != 0)
{
await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();

View File

@@ -16,8 +16,8 @@ public record SynchronizeJellyfinLibraryByIdIfNeeded(int JellyfinLibraryId) : IS
public bool DeepScan => false;
}
public record ForceSynchronizeJellyfinLibraryById
(int JellyfinLibraryId, bool DeepScan) : ISynchronizeJellyfinLibraryById
public record ForceSynchronizeJellyfinLibraryById(int JellyfinLibraryId, bool DeepScan)
: ISynchronizeJellyfinLibraryById
{
public bool ForceScan => true;
}

View File

@@ -2,7 +2,7 @@
namespace ErsatzTV.Application.Jellyfin;
public record UpdateJellyfinLibraryPreferences
(List<JellyfinLibraryPreference> Preferences) : IRequest<Either<BaseError, Unit>>;
public record UpdateJellyfinLibraryPreferences(List<JellyfinLibraryPreference> Preferences)
: IRequest<Either<BaseError, Unit>>;
public record JellyfinLibraryPreference(int Id, bool ShouldSyncItems);

View File

@@ -6,7 +6,7 @@ namespace ErsatzTV.Application.Jellyfin;
public class
UpdateJellyfinLibraryPreferencesHandler : IRequestHandler<UpdateJellyfinLibraryPreferences,
Either<BaseError, Unit>>
Either<BaseError, Unit>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;
private readonly ISearchIndex _searchIndex;

View File

@@ -4,9 +4,9 @@ using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.Jellyfin;
public record JellyfinLibraryViewModel(
int Id,
string Name,
LibraryMediaKind MediaKind,
bool ShouldSyncItems,
int MediaSourceId)
int Id,
string Name,
LibraryMediaKind MediaKind,
bool ShouldSyncItems,
int MediaSourceId)
: LibraryViewModel("Jellyfin", Id, Name, MediaKind, MediaSourceId, string.Empty);

View File

@@ -5,7 +5,7 @@ namespace ErsatzTV.Application.Jellyfin;
public class
GetAllJellyfinMediaSourcesHandler : IRequestHandler<GetAllJellyfinMediaSources,
List<JellyfinMediaSourceViewModel>>
List<JellyfinMediaSourceViewModel>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

View File

@@ -5,7 +5,7 @@ namespace ErsatzTV.Application.Jellyfin;
public class
GetJellyfinLibrariesBySourceIdHandler : IRequestHandler<GetJellyfinLibrariesBySourceId,
List<JellyfinLibraryViewModel>>
List<JellyfinLibraryViewModel>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

View File

@@ -1,4 +1,3 @@
namespace ErsatzTV.Application.Jellyfin;
public record GetJellyfinMediaSourceById
(int JellyfinMediaSourceId) : IRequest<Option<JellyfinMediaSourceViewModel>>;
public record GetJellyfinMediaSourceById(int JellyfinMediaSourceId) : IRequest<Option<JellyfinMediaSourceViewModel>>;

View File

@@ -5,7 +5,7 @@ namespace ErsatzTV.Application.Jellyfin;
public class
GetJellyfinMediaSourceByIdHandler : IRequestHandler<GetJellyfinMediaSourceById,
Option<JellyfinMediaSourceViewModel>>
Option<JellyfinMediaSourceViewModel>>
{
private readonly IMediaSourceRepository _mediaSourceRepository;

View File

@@ -1,4 +1,4 @@
namespace ErsatzTV.Application.Jellyfin;
public record GetJellyfinPathReplacementsBySourceId
(int JellyfinMediaSourceId) : IRequest<List<JellyfinPathReplacementViewModel>>;
public record GetJellyfinPathReplacementsBySourceId(int JellyfinMediaSourceId)
: IRequest<List<JellyfinPathReplacementViewModel>>;

View File

@@ -13,6 +13,7 @@ using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting.Compact.Reader;
@@ -20,11 +21,14 @@ namespace ErsatzTV.Application.Libraries;
public abstract class CallLibraryScannerHandler<TRequest>
{
private readonly int _batchSize = 100;
private readonly ChannelWriter<ISearchIndexBackgroundServiceRequest> _channel;
private readonly IConfigElementRepository _configElementRepository;
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IMediator _mediator;
private readonly IRuntimeInfo _runtimeInfo;
private readonly List<int> _toReindex = [];
private readonly List<int> _toRemove = [];
private string _libraryName;
protected CallLibraryScannerHandler(
@@ -65,6 +69,18 @@ public abstract class CallLibraryScannerHandler<TRequest>
{
return BaseError.New($"ErsatzTV.Scanner exited with code {process.ExitCode}");
}
if (_toReindex.Count > 0)
{
await _channel.WriteAsync(new ReindexMediaItems(_toReindex.ToArray()), cancellationToken);
_toReindex.Clear();
}
if (_toRemove.Count > 0)
{
await _channel.WriteAsync(new RemoveMediaItems(_toReindex.ToArray()), cancellationToken);
_toRemove.Clear();
}
}
catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException)
{
@@ -84,7 +100,16 @@ public abstract class CallLibraryScannerHandler<TRequest>
// because the compact json writer used by the scanner
// writes in UTC
LogEvent logEvent = LogEventReader.ReadFromString(s);
Log.Write(
ILogger log = Log.Logger;
if (logEvent.Properties.TryGetValue("SourceContext", out LogEventPropertyValue property))
{
log = log.ForContext(
Constants.SourceContextPropertyName,
property.ToString().Trim('"'));
}
log.Write(
new LogEvent(
logEvent.Timestamp.ToLocalTime(),
logEvent.Level,
@@ -113,6 +138,20 @@ public abstract class CallLibraryScannerHandler<TRequest>
_libraryName = progressUpdate.LibraryName;
}
_toReindex.AddRange(progressUpdate.ItemsToReindex);
if (_toReindex.Count >= _batchSize)
{
await _channel.WriteAsync(new ReindexMediaItems(_toReindex.ToArray()));
_toReindex.Clear();
}
_toRemove.AddRange(progressUpdate.ItemsToRemove);
if (_toRemove.Count >= _batchSize)
{
await _channel.WriteAsync(new RemoveMediaItems(_toReindex.ToArray()));
_toRemove.Clear();
}
if (progressUpdate.PercentComplete is not null)
{
var progress = new LibraryScanProgress(
@@ -121,18 +160,6 @@ public abstract class CallLibraryScannerHandler<TRequest>
await _mediator.Publish(progress);
}
if (progressUpdate.ItemsToReindex.Length > 0)
{
var reindex = new ReindexMediaItems(progressUpdate.ItemsToReindex);
await _channel.WriteAsync(reindex);
}
if (progressUpdate.ItemsToRemove.Length > 0)
{
var remove = new RemoveMediaItems(progressUpdate.ItemsToRemove);
await _channel.WriteAsync(remove);
}
}
}
catch (Exception ex)
@@ -166,9 +193,16 @@ public abstract class CallLibraryScannerHandler<TRequest>
: "ErsatzTV.Scanner";
string processFileName = Environment.ProcessPath ?? string.Empty;
if (!string.IsNullOrWhiteSpace(processFileName))
string processExecutable = Path.GetFileNameWithoutExtension(processFileName);
string folderName = Path.GetDirectoryName(processFileName);
if ("dotnet".Equals(processExecutable, StringComparison.OrdinalIgnoreCase))
{
string localFileName = Path.Combine(Path.GetDirectoryName(processFileName) ?? string.Empty, executable);
folderName = AppContext.BaseDirectory;
}
if (!string.IsNullOrWhiteSpace(folderName))
{
string localFileName = Path.Combine(folderName, executable);
if (File.Exists(localFileName))
{
return localFileName;

View File

@@ -32,7 +32,7 @@ public class CreateLocalLibraryHandler : LocalLibraryHandlerBase,
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, LocalLibrary> validation = await Validate(dbContext, request);
return await LanguageExtensions.Apply(validation, localLibrary => PersistLocalLibrary(dbContext, localLibrary));
return await validation.Apply(localLibrary => PersistLocalLibrary(dbContext, localLibrary));
}
private async Task<LocalLibraryViewModel> PersistLocalLibrary(

View File

@@ -2,5 +2,5 @@
namespace ErsatzTV.Application.Libraries;
public record CreateLocalLibraryPath
(int LibraryId, string Path) : IRequest<Either<BaseError, LocalLibraryPathViewModel>>;
public record CreateLocalLibraryPath(int LibraryId, string Path)
: IRequest<Either<BaseError, LocalLibraryPathViewModel>>;

View File

@@ -14,9 +14,7 @@ public class DeleteLocalLibraryHandler : LocalLibraryHandlerBase,
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly ISearchIndex _searchIndex;
public DeleteLocalLibraryHandler(
IDbContextFactory<TvContext> dbContextFactory,
ISearchIndex searchIndex)
public DeleteLocalLibraryHandler(IDbContextFactory<TvContext> dbContextFactory, ISearchIndex searchIndex)
{
_dbContextFactory = dbContextFactory;
_searchIndex = searchIndex;
@@ -28,21 +26,46 @@ public class DeleteLocalLibraryHandler : LocalLibraryHandlerBase,
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, LocalLibrary> validation = await LocalLibraryMustExist(dbContext, request);
return await LanguageExtensions.Apply(validation, localLibrary => DoDeletion(dbContext, localLibrary));
return await validation.Apply(localLibrary => DoDeletion(dbContext, localLibrary));
}
private async Task<Unit> DoDeletion(TvContext dbContext, LocalLibrary localLibrary)
{
List<int> ids = await dbContext.Connection.QueryAsync<int>(
@"SELECT MediaItem.Id FROM MediaItem
INNER JOIN LibraryPath LP on MediaItem.LibraryPathId = LP.Id
WHERE LP.LibraryId = @LibraryId",
"""
SELECT MediaItem.Id FROM MediaItem
INNER JOIN LibraryPath LP on MediaItem.LibraryPathId = LP.Id
WHERE LP.LibraryId = @LibraryId
""",
new { LibraryId = localLibrary.Id })
.Map(result => result.ToList());
await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
await dbContext.Connection.ExecuteAsync(
"""
DELETE FROM MediaItem WHERE Id IN
(
SELECT MI.Id FROM MediaItem MI
INNER JOIN LibraryPath LP ON MI.LibraryPathId = LP.Id
WHERE LP.LibraryId = @LibraryId
)
""",
new { LibraryId = localLibrary.Id });
// delete all library folders (children first)
IOrderedQueryable<LibraryFolder> orderedFolders = dbContext.LibraryFolders
.Filter(lf => lf.LibraryPath.LibraryId == localLibrary.Id)
.OrderByDescending(lp => lp.Path.Length);
foreach (LibraryFolder folder in orderedFolders)
{
await dbContext.Connection.ExecuteAsync(
"DELETE FROM LibraryFolder WHERE Id = @LibraryFolderId",
new { LibraryFolderId = folder.Id });
}
dbContext.LocalLibraries.Remove(localLibrary);
await dbContext.SaveChangesAsync();

View File

@@ -39,7 +39,7 @@ public class MoveLocalLibraryPathHandler : IRequestHandler<MoveLocalLibraryPath,
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await LanguageExtensions.Apply(validation, parameters => MovePath(dbContext, parameters));
return await validation.Apply(parameters => MovePath(dbContext, parameters));
}
private async Task<Unit> MovePath(TvContext dbContext, Parameters parameters)

View File

@@ -1,4 +1,5 @@
using System.Threading.Channels;
using Dapper;
using ErsatzTV.Application.MediaSources;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
@@ -37,7 +38,7 @@ public class UpdateLocalLibraryHandler : LocalLibraryHandlerBase,
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await LanguageExtensions.Apply(validation, parameters => UpdateLocalLibrary(dbContext, parameters));
return await validation.Apply(parameters => UpdateLocalLibrary(dbContext, parameters));
}
private async Task<LocalLibraryViewModel> UpdateLocalLibrary(TvContext dbContext, Parameters parameters)
@@ -54,16 +55,36 @@ public class UpdateLocalLibraryHandler : LocalLibraryHandlerBase,
var toRemoveIds = toRemove.Map(lp => lp.Id).ToList();
List<int> itemsToRemove = await dbContext.MediaItems
.Filter(mi => toRemoveIds.Contains(mi.LibraryPathId))
.Map(mi => mi.Id)
.ToListAsync();
await dbContext.Connection.ExecuteAsync(
"DELETE FROM MediaItem WHERE LibraryPathId IN @Ids",
new { Ids = toRemoveIds });
// delete all library folders (children first)
IOrderedQueryable<LibraryFolder> orderedFolders = dbContext.LibraryFolders
.Filter(lf => toRemoveIds.Contains(lf.LibraryPathId))
.OrderByDescending(lp => lp.Path.Length);
foreach (LibraryFolder folder in orderedFolders)
{
await dbContext.Connection.ExecuteAsync(
"DELETE FROM LibraryFolder WHERE Id = @LibraryFolderId",
new { LibraryFolderId = folder.Id });
}
await dbContext.LibraryPaths
.Filter(lp => toRemoveIds.Contains(lp.Id))
.ExecuteDeleteAsync();
existing.Paths.RemoveAll(toRemove.Contains);
existing.Paths.AddRange(toAdd);
if (await dbContext.SaveChangesAsync() > 0)
{
List<int> itemsToRemove = await dbContext.MediaItems
.AsNoTracking()
.Filter(mi => toRemoveIds.Contains(mi.LibraryPathId))
.Map(mi => mi.Id)
.ToListAsync();
await _searchIndex.RemoveItems(itemsToRemove);
_searchIndex.Commit();
}

View File

@@ -3,9 +3,9 @@
namespace ErsatzTV.Application.Libraries;
public record PlexLibraryViewModel(
int Id,
string Name,
LibraryMediaKind MediaKind,
int MediaSourceId,
string MediaSourceName)
int Id,
string Name,
LibraryMediaKind MediaKind,
int MediaSourceId,
string MediaSourceName)
: LibraryViewModel("Plex", Id, Name, MediaKind, MediaSourceId, MediaSourceName);

View File

@@ -15,20 +15,51 @@ public class GetExternalCollectionsHandler : IRequestHandler<GetExternalCollecti
GetExternalCollections request,
CancellationToken cancellationToken)
{
List<LibraryViewModel> result = new();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
List<int> mediaSourceIds = await dbContext.EmbyMediaSources
result.AddRange(await GetEmbyExternalCollections(dbContext, cancellationToken));
result.AddRange(await GetJellyfinExternalCollections(dbContext, cancellationToken));
result.AddRange(await GetPlexExternalCollections(dbContext, cancellationToken));
return result;
}
private static async Task<IEnumerable<LibraryViewModel>> GetEmbyExternalCollections(
TvContext dbContext,
CancellationToken cancellationToken)
{
List<int> embyMediaSourceIds = await dbContext.EmbyMediaSources
.Filter(ems => ems.Libraries.Any(l => ((EmbyLibrary)l).ShouldSyncItems))
.Map(ems => ems.Id)
.ToListAsync(cancellationToken);
return mediaSourceIds.Map(
id => new LibraryViewModel(
"Emby",
0,
"Collections",
0,
id,
string.Empty))
.ToList();
return embyMediaSourceIds.Map(id => new LibraryViewModel("Emby", 0, "Collections", 0, id, string.Empty));
}
private static async Task<IEnumerable<LibraryViewModel>> GetJellyfinExternalCollections(
TvContext dbContext,
CancellationToken cancellationToken)
{
List<int> jellyfinMediaSourceIds = await dbContext.JellyfinMediaSources
.Filter(jms => jms.Libraries.Any(l => ((JellyfinLibrary)l).ShouldSyncItems))
.Map(jms => jms.Id)
.ToListAsync(cancellationToken);
return jellyfinMediaSourceIds.Map(
id => new LibraryViewModel("Jellyfin", 0, "Collections", 0, id, string.Empty));
}
private static async Task<IEnumerable<LibraryViewModel>> GetPlexExternalCollections(
TvContext dbContext,
CancellationToken cancellationToken)
{
List<int> plexMediaSourceIds = await dbContext.PlexMediaSources
.Filter(pms => pms.Libraries.Any(l => ((PlexLibrary)l).ShouldSyncItems))
.Map(pms => pms.Id)
.ToListAsync(cancellationToken);
return plexMediaSourceIds.Map(
id => new LibraryViewModel("Plex", 0, "Collections", 0, id, string.Empty));
}
}

View File

@@ -27,7 +27,7 @@ public class ReleaseMemoryHandler : IRequestHandler<ReleaseMemory>
return Task.CompletedTask;
}
bool hasActiveWorkers = _ffmpegSegmenterService.SessionWorkers.Any() || FFmpegProcess.ProcessCount > 0;
bool hasActiveWorkers = _ffmpegSegmenterService.Workers.Count >= 0 || FFmpegProcess.ProcessCount > 0;
if (request.ForceAggressive || !hasActiveWorkers)
{
_logger.LogDebug("Starting aggressive garbage collection");

View File

@@ -2,8 +2,7 @@
namespace ErsatzTV.Application.MediaCards;
public record ArtistCardViewModel
(
public record ArtistCardViewModel(
int ArtistId,
string Title,
string Subtitle,

View File

@@ -9,7 +9,8 @@ public record CollectionCardResultsViewModel(
List<ArtistCardViewModel> ArtistCards,
List<MusicVideoCardViewModel> MusicVideoCards,
List<OtherVideoCardViewModel> OtherVideoCards,
List<SongCardViewModel> SongCards)
List<SongCardViewModel> SongCards,
List<ImageCardViewModel> ImageCards)
{
public bool UseCustomPlaybackOrder { get; set; }
}

View File

@@ -0,0 +1,5 @@
using ErsatzTV.Core.Search;
namespace ErsatzTV.Application.MediaCards;
public record ImageCardResultsViewModel(int Count, List<ImageCardViewModel> Cards, SearchPageMap PageMap);

View File

@@ -0,0 +1,20 @@
using ErsatzTV.Core.Domain;
namespace ErsatzTV.Application.MediaCards;
public record ImageCardViewModel(
int ImageId,
string Title,
string Subtitle,
string SortTitle,
string Poster,
MediaItemState State) : MediaCardViewModel(
ImageId,
Title,
Subtitle,
SortTitle,
Poster,
State)
{
public int CustomIndex { get; set; }
}

View File

@@ -131,12 +131,21 @@ internal static class Mapper
return new SongCardViewModel(
songMetadata.SongId,
songMetadata.Title,
songMetadata.Artist + album,
string.Join(", ", songMetadata.Artists) + album,
songMetadata.SortTitle,
GetThumbnail(songMetadata, None, None),
songMetadata.Song.State);
}
internal static ImageCardViewModel ProjectToViewModel(ImageMetadata imageMetadata) =>
new(
imageMetadata.ImageId,
imageMetadata.Title,
imageMetadata.OriginalTitle,
imageMetadata.SortTitle,
string.Empty, // TODO: thumbnail?
imageMetadata.Image.State);
internal static ArtistCardViewModel ProjectToViewModel(ArtistMetadata artistMetadata) =>
new(
artistMetadata.ArtistId,
@@ -152,30 +161,38 @@ internal static class Mapper
Option<JellyfinMediaSource> maybeJellyfin,
Option<EmbyMediaSource> maybeEmby) =>
new(
collection.Name,
collection.MediaItems.OfType<Movie>().Map(
m => ProjectToViewModel(m.MovieMetadata.Head(), maybeJellyfin, maybeEmby) with
{
CustomIndex = GetCustomIndex(collection, m.Id)
}).ToList(),
collection.MediaItems.OfType<Show>()
.Map(s => ProjectToViewModel(s.ShowMetadata.Head(), maybeJellyfin, maybeEmby))
.ToList(),
collection.MediaItems.OfType<Season>().Map(s => ProjectToViewModel(s, maybeJellyfin, maybeEmby))
.ToList(),
// collection view doesn't use local paths
collection.MediaItems.OfType<Episode>()
.Map(e => ProjectToViewModel(e.EpisodeMetadata.Head(), maybeJellyfin, maybeEmby, false, string.Empty))
.ToList(),
collection.MediaItems.OfType<Artist>().Map(a => ProjectToViewModel(a.ArtistMetadata.Head())).ToList(),
// collection view doesn't use local paths
collection.MediaItems.OfType<MusicVideo>()
.Map(mv => ProjectToViewModel(mv.MusicVideoMetadata.Head(), string.Empty))
.ToList(),
collection.MediaItems.OfType<OtherVideo>().Map(ov => ProjectToViewModel(ov.OtherVideoMetadata.Head()))
.ToList(),
collection.MediaItems.OfType<Song>().Map(s => ProjectToViewModel(s.SongMetadata.Head()))
.ToList()) { UseCustomPlaybackOrder = collection.UseCustomPlaybackOrder };
collection.Name,
collection.MediaItems.OfType<Movie>().Map(
m => ProjectToViewModel(m.MovieMetadata.Head(), maybeJellyfin, maybeEmby) with
{
CustomIndex = GetCustomIndex(collection, m.Id)
}).ToList(),
collection.MediaItems.OfType<Show>()
.Map(s => ProjectToViewModel(s.ShowMetadata.Head(), maybeJellyfin, maybeEmby))
.ToList(),
collection.MediaItems.OfType<Season>().Map(s => ProjectToViewModel(s, maybeJellyfin, maybeEmby))
.ToList(),
// collection view doesn't use local paths
collection.MediaItems.OfType<Episode>()
.Map(
e => ProjectToViewModel(
e.EpisodeMetadata.Head(),
maybeJellyfin,
maybeEmby,
false,
string.Empty))
.ToList(),
collection.MediaItems.OfType<Artist>().Map(a => ProjectToViewModel(a.ArtistMetadata.Head())).ToList(),
// collection view doesn't use local paths
collection.MediaItems.OfType<MusicVideo>()
.Map(mv => ProjectToViewModel(mv.MusicVideoMetadata.Head(), string.Empty))
.ToList(),
collection.MediaItems.OfType<OtherVideo>().Map(ov => ProjectToViewModel(ov.OtherVideoMetadata.Head()))
.ToList(),
collection.MediaItems.OfType<Song>().Map(s => ProjectToViewModel(s.SongMetadata.Head()))
.ToList(),
collection.MediaItems.OfType<Image>().Map(i => ProjectToViewModel(i.ImageMetadata.Head())).ToList())
{ UseCustomPlaybackOrder = collection.UseCustomPlaybackOrder };
internal static ActorCardViewModel ProjectToViewModel(
Actor actor,

View File

@@ -2,8 +2,7 @@
namespace ErsatzTV.Application.MediaCards;
public record MovieCardViewModel
(
public record MovieCardViewModel(
int MovieId,
string Title,
string Subtitle,

View File

@@ -2,8 +2,7 @@
namespace ErsatzTV.Application.MediaCards;
public record MusicVideoCardViewModel
(
public record MusicVideoCardViewModel(
int MusicVideoId,
string Title,
string Subtitle,

View File

@@ -2,8 +2,7 @@
namespace ErsatzTV.Application.MediaCards;
public record OtherVideoCardViewModel
(
public record OtherVideoCardViewModel(
int OtherVideoId,
string Title,
string Subtitle,

View File

@@ -1,4 +1,3 @@
namespace ErsatzTV.Application.MediaCards;
public record GetMusicVideoCards
(int ArtistId, int PageNumber, int PageSize) : IRequest<MusicVideoCardResultsViewModel>;
public record GetMusicVideoCards(int ArtistId, int PageNumber, int PageSize) : IRequest<MusicVideoCardResultsViewModel>;

View File

@@ -1,4 +1,4 @@
namespace ErsatzTV.Application.MediaCards;
public record GetTelevisionEpisodeCards
(int TelevisionSeasonId, int PageNumber, int PageSize) : IRequest<TelevisionEpisodeCardResultsViewModel>;
public record GetTelevisionEpisodeCards(int TelevisionSeasonId, int PageNumber, int PageSize)
: IRequest<TelevisionEpisodeCardResultsViewModel>;

View File

@@ -1,4 +1,4 @@
namespace ErsatzTV.Application.MediaCards;
public record GetTelevisionSeasonCards
(int TelevisionShowId, int PageNumber, int PageSize) : IRequest<TelevisionSeasonCardResultsViewModel>;
public record GetTelevisionSeasonCards(int TelevisionShowId, int PageNumber, int PageSize)
: IRequest<TelevisionSeasonCardResultsViewModel>;

Some files were not shown because too many files have changed in this diff Show More