NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support v
« Previous 1 … 16 17 18 19 20 … 43 Next »
Prefer SD or HD channel when advanced recording on keyword

 
  • 0 Vote(s) - 0 Average
Prefer SD or HD channel when advanced recording on keyword
janoonk
Offline

Member

Netherlands
Posts: 105
Threads: 33
Joined: Dec 2020
#1
2021-12-24, 02:18 PM
In the past when the HD channels were still named ".... HD" I could easily make a Advanced recording like this:
`title like '%Christmas%' and genres like '%Movie / Drama%' and channel_oid in (select oid from channel where name not like '% HD')`


But the channels have been renamed by the provider and all are now HD and the ones that are still SD has SD in their channel name for example "RTL" (=HD) and "RTL SD" (=SD).
I want to record all EPG events that are a movie and contain a keyword for example `Christmas`. But most of the time the event is broadcasted on both SD and HD channels. To save some diskspace and prevent double recordings I want to prefer HD over SD (or vice versa).
To complicate it further sometimes the movie is broadcasted on even more than 2 channels for example: RTL, RTL SD and Film1 Family. How to prevent double recordings of the same movie or is this automatically done by NextPVR?

Am I correct that the advanced textbox can only contain a filter and subquery or can I also do a complete custom SQL query?
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,850
Threads: 954
Joined: May 2006
#2
2021-12-24, 02:37 PM (This post was last modified: 2021-12-24, 05:40 PM by mvallevand.)
Can't you simply reverse the logic and for HD they are "not like %SD" and "like %SD" for SD

If you have a good EPG source like Schedules that provides a unique ID than duplicates will not be recorded. If it doesn't have a unique id the if the source has the movie year and identifies it as a movie it is possible that NextPVR generates an internal unique id.

If you turn on ExtendedLogging in config.xml, not to be confused with Verbose logging, you will see how it is constructed in the logs

Code:
SQL: select * from EPG_EVENT where ... order by start_time

your query would replace the ellipsis

Martin
janoonk
Offline

Member

Netherlands
Posts: 105
Threads: 33
Joined: Dec 2020
#3
2021-12-24, 04:46 PM (This post was last modified: 2021-12-24, 05:01 PM by janoonk.)
I managed to get it working with some SQL magic. It prefers SD and it will prevent double recordings even when on multiple channels!



Code:
select  *
from EPG_EVENT
where title like '%Christmas%'
and genres like '%Movie / Drama%'
and oid in (
select oid
from (
select ee2.oid,1 as nr
from EPG_EVENT ee2, CHANNEL c
where ee2.channel_oid=c.oid
and ee2.title=EPG_EVENT.title
and c.name like '% SD'
UNION
select ee2.oid,2 as nr
from EPG_EVENT ee2, CHANNEL c
where ee2.channel_oid=c.oid
and ee2.title=EPG_EVENT.title
and c.name not like '% SD'
)
order by nr asc
limit 1
)
order by title



and by creating an index on title column. Query time went from 40sec to 0,2s !




Code:
CREATE INDEX EPG_EVENT_title
ON EPG_EVENT(title);
janoonk
Offline

Member

Netherlands
Posts: 105
Threads: 33
Joined: Dec 2020
#4
2021-12-28, 10:22 PM (This post was last modified: 2021-12-28, 10:24 PM by janoonk.)
(2021-12-24, 04:46 PM)janoonk Wrote: I managed to get it working with some SQL magic. It prefers SD and it will prevent double recordings even when on multiple channels!
Made a small fix/update for some edge case where a epg_event with a certain name existed multiple times and with two different genres (it was both a movie / drama and a regular broadcast) and were two different things.
If you prefer HD over SD: change `ORDER BY nr ASC` into `ORDER BY nr DESC`
Just copy/paste below in Advanced recording textbox:

Code:
genres LIKE '%Movie / Drama%'
AND oid IN (
    SELECT oid
    FROM (
        SELECT ee2.oid, 1 AS nr
        FROM EPG_EVENT ee2, CHANNEL c
        WHERE ee2.channel_oid = c.oid
        AND ee2.title = EPG_EVENT.title
        AND ee2.genres LIKE '%Movie / Drama%'
        AND c.name LIKE '% SD'
        
        UNION
        
        SELECT ee2.oid, 2 AS nr
        FROM EPG_EVENT ee2, CHANNEL c
        WHERE ee2.channel_oid = c.oid
        AND ee2.title = EPG_EVENT.title
        AND ee2.genres LIKE '%Movie / Drama%'
        AND c.name NOT LIKE '% SD'
    )
    ORDER BY nr ASC
        limit 1
)
AND imdb_rating >= 8
AND imdb_votes >= 10000

and by creating multiple indexes: title, genres, name columns. Query time went from 40sec to 0,2s !

Code:
CREATE INDEX EPG_EVENT_title
ON EPG_EVENT(title);
janoonk
Offline

Member

Netherlands
Posts: 105
Threads: 33
Joined: Dec 2020
#5
2022-01-03, 10:18 AM (This post was last modified: 2022-01-03, 10:20 AM by janoonk.)
I updated above query to prevent double recordings.
Use this query in NextPVR as Advanced Recording type (be sure to name it "Top movies" as the query uses this name):
Code:
genres LIKE '%Movie / Drama%'
AND oid IN (
    SELECT oid     
    FROM (
        SELECT ee2.oid,1 AS nr         
        FROM EPG_EVENT ee2,CHANNEL c
        WHERE ee2.channel_oid = c.oid
        AND ee2.title = EPG_EVENT.title         
        AND ee2.genres LIKE '%Movie / Drama%'         
        AND c.name LIKE '% SD'
        UNION                  
        SELECT ee2.oid,2 AS nr         
        FROM EPG_EVENT ee2,CHANNEL c         
        WHERE ee2.channel_oid = c.oid         
        AND ee2.title = EPG_EVENT.title         
        AND ee2.genres LIKE '%Movie / Drama%'         
        AND c.name NOT LIKE '% SD'     
    )     
    ORDER BY nr ASC
    limit 1
)
AND imdb_rating >= 8
AND imdb_votes >= 10000
and title not in (
    select DISTINCT(name)
    from SCHEDULED_RECORDING sr
    where sr.filename like '%/Top movies/%'
    and sr.status=2
)

If you want to test the query in like DB Browser for SQLite use this query (adjust columns in first select if you want):
Code:
select e.title,c.name
from EPG_EVENT e, CHANNEL c
where e.channel_oid=c.oid
and genres LIKE '%Movie / Drama%'
AND e.oid IN (
    SELECT oid     
    FROM (
        SELECT ee2.oid,1 AS nr         
        FROM EPG_EVENT ee2,CHANNEL c
        WHERE ee2.channel_oid = c.oid
        AND ee2.title = e.title         
        AND ee2.genres LIKE '%Movie / Drama%'         
        AND c.name LIKE '% SD'
        UNION                  
        SELECT ee2.oid,2 AS nr         
        FROM EPG_EVENT ee2,CHANNEL c         
        WHERE ee2.channel_oid = c.oid         
        AND ee2.title = e.title         
        AND ee2.genres LIKE '%Movie / Drama%'         
        AND c.name NOT LIKE '% SD'     
    )     
    ORDER BY nr ASC
    limit 1
)
AND imdb_rating >= 8
AND imdb_votes >= 10000
and e.title not in (
    select DISTINCT(name)
    from SCHEDULED_RECORDING sr
    where sr.filename like '%/Top movies/%'
    and sr.status=2
)
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Recording from the point you switch channels rather than when you press record Swindiff 2 200 2025-05-05, 12:30 PM
Last Post: Swindiff
  Controlling the nextpvr server from Jellyfin (via the nextpvr plugin) (no recording) kfmf 2 261 2025-05-04, 02:21 PM
Last Post: mvallevand
  Keeping users recording separate Swindiff 2 205 2025-05-02, 07:47 PM
Last Post: Swindiff
  Recurring recording creates multiple recordings of same event txinga 2 341 2025-03-29, 12:33 AM
Last Post: txinga
Photo EPG Channel sort order spagio 3 367 2025-03-02, 05:28 PM
Last Post: sub
  Channel Editor -- Feature Request? BigKahuna 1 288 2025-02-19, 06:50 PM
Last Post: sub
  Recording Auto Transcode VCR58 8 1,708 2025-02-18, 12:45 AM
Last Post: mvallevand
Question extras.xml | channel management D3iver 3 371 2025-01-12, 09:05 PM
Last Post: mvallevand
  Automated placement based on recording type? ehfortin 6 561 2024-12-28, 11:50 PM
Last Post: spin35
  HDHR Tuner not released after recording since update to 7.0.0 spin35 1 340 2024-12-24, 01:46 PM
Last Post: mvallevand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode