Some broadcasts can have different charsets (such as iso-8859-1) but
we assume utf-8 unless user has set it correctly. So when decode fails
we get an exception. So we now attempt to decode with error
replacement so user sees incorrect character.
This gives "u'Denise Th\ufffd\ufffd':" as the string returned instead
when the received name contains an é that is in iso-8859-1 instead of
utf-8.
Ensure files are compatible with python2 and python3.
Main differences:
- print requires brackets
- string is bytes in python2 and unicode in python3
- need to use struct to pack/unpack binary data
- need to convert socket data to bytearray to allow data extraction
Old dvr_entry records (tvh4.2) do not have a create timestamp, so we
fake one based on the start time of the recording. This will allow
us to send the timestamp to the UI in the future knowing that it
will give consistent results for user sorting since it may be
useful for user to sort upcoming recordings by when they were
created (i.e., scheduled).
We have to ensure we don't async reschedule if we have only just been
created then destroyed, otherwise we can enter a loop where every few
minutes the autorec is checked, realizes it can schedule against a
current broadcast, create the dvr_entry, then find it's a duplicate
of an existing recording/dvr_entry, so destroy the new entry, which
then causes the loop to start again later.
So, if a dvr_entry is created and destroy quickly then we avoid
the async reschedule. This breaks the loop since we no longer
trigger a second async reschedule.
dvr: Mark dvr entries as duplicates early to avoid logging.
When autorecs are modified, we can do an async reschedule to ensure
recordings are correctly updated in case the autorecs interact.
However this can cause excessve logging in some circumstances.
Effectively, if there is a recording on disk and the autorec matches
the same recording in the future then the dvr_entry_create_by_autorec
can exit the "bcast" loop with no match at all (since entry on disk
frequently, but not always, has a null de_bcast).
This then means we create the dvr_entry, and, if the programme is
broadcasting now, then we immediately schedule a timer to start the
recording and log an info to say scheduled. We then immediately cancel
the recording, delete the dvr_entry, which then causes us do an async
schedule. But this async schedule realizes the autorec matches the
broadcast, so we go through the process again.
So, first stage is to delete the duplicate before we do any logging.
Unfortunately, due to the way dup matching works (only dvr entry vs
dvr entry, not vs bcast), we have to create a dvr_entry to do the
matching.
We also need to check duplicate event after it is inserted in to
de_global_link (to avoid assertion fault).
dvr: Ensure non-scheduled dvr_entry is always "best".
Previously in dvr_is_better_recording_timeslot we would sanity check
that the old channel and broadcast exists before further checks.
However, it probably makes sense to ensure that a non-scheduled
dvr_entry (such as already recorded) is always the better match even
though it might not be linked to any broadcasts.
webui: Add Previous button to epg and dvr, fix minor issues (If you select the first/last row the previous/next are active when the popup window is opened first time)
FreeBSD: Support different stat format in Makefile.webui.
The stat program on FreeBSD requires different arguments to GNU
stat. In the past, this is done by the ports patching the Makefile
post-extract.
Instead, we'll configure the program's arguments based on platform.
We'll also use %z (filesize) instead of the port's %b (file blocks) so
we generate equivalent output to the Linux version..
dvr: Async reschedule autorecs whenever a log entry is destroyed.
Destroying a log entry can cause another autorec rule to be valid and
need scheduling.
For example, if you have two autorec rules that match the same
programme then only one autorec rule will schedule the programme
and the other autorec will see the programme is scheduled and do
nothing.
However, if you then disable the first autorec rule, then we need the
second autorec rule to re-arm the timer for that programme since it
still matches it.
This resheduling is done async after a delay. This avoids large
changes causing constant rescheduling. So, if user deletes a thousand
log files, we do not want a thousand reschedules to occur. Instead,
we dispatch a single timer after the last update has occurred.
My listings provider thinks every old film is worth 5/5, so we add
minyear to allow an autorec of "good films" to filter out old
films. Also add corresponding maxyear for people who think the
opposite and only want old programmes recorded.
ui: Fix createToolbar2 issues on some recent browsers.
Recent versions of Firefox had an exception saying the createToolbar2
function does not exist when it was called to create the secondary
toolbar that is used for category searching in the EPG.
I believe this was due to scoping issues, so rescoped the variables.
This worked, but although the toolbar was added it was not displayed
on Firefox. So changed the way the toolbar is added and it now works
on Firefox and Safari.
The official build runs with gcc which checks for some incompatible
pointers for assignment of const to non-const, whereas clang
build disabled such warnings.
So, update to re-enable the check on clang and fixup couple of
locations that failed.
dvr: Avoid recording partial programme if autorec created mid-programme.
When creating an autorec, it can match a programme that has already
started. If so, it's better to prefer the later recording so you get a
full recording.
So, if it's 09:10 and there is an hour long programme that started at
09:00 but is repeated at 10:00, then let's record at 10:00 instead and
get the full hour, instead of at 09:10 and only get 50 minutes.
dvr: Only do time slot scheduling in the scheduled state.
We do not want a currently recording programme to be cancelled
due to a better channel being found. For example recording a SD
channel and then the OTA updates and finds an HD version of the
show at the same time and so tries to schedule that HD version
instead.
The configuration to enable finding a 'best' time slot for
recording is now configurable as an advanced option in
Configuration->Recording->DVR Profiles, with the default being
disabled.
When toggled, the autorec rules themselves need to be manually
toggled to cause them to reschedule.
dvr: Prefer earlier/better schedule events for autorecs.
We now try to avoid scheduling on a timeshift channel X+1 if we have
the same programme on channel X. If a programme is on at the same time
on multiple channels then we will try and schedule on a better
channel, such as one with more services (such as mixed DVB-T/DVB-S) to
allow service switching fallback on tuner conflict.
An example of the new log entry:
dvr: Autorecord "movie misc" Replacing existing dvr recording entry of
"The Departed" on ITV4+1 @ start 2018-09-20;00:35:00(+0100) with
recording on ITV4 @ start 2018-09-19;23:35:00(+0100)
Context for the change is below:
In some areas, a broadcast programme might be shown at the same time
on multiple channels, or at different times on various timeshift,
repeat, or regional channels.
An example of this is the Astra 28.2E satellite where BBC1 has
multiple (26) regional channels that (mostly) show the same
programmes, but sometimes a region might have a +30m or +1h timeshift
for a single programme.
Similarly the commercial channel "Channel 4" has "Channel 4+1", and a
repeat channel of "4Seven" and various associated HD channels. Homes
receive all these regional channels via one dish and are required for
BBC to manually switch between HD/SD versions for local interest
programmes such as regional news.
Previously, when setting an autorec, the item chosen to record was
based on the first broadcast that matched the criteria (such as film
title). However, this broadcast is not necessarily the earliest or the
best.
So this meant that with timeshift channels, a programme could be
scheduled on X+1 instead of X, so record at 21:00 instead of 20:00.
On other setups, the event might correctly record at 20:00, since
scheduling depended on internal structures and which broadcasts are
found first (such as via OTA updates).
Similarly, in countries where the same programme can be received but
on different channels in different qualities, it was possible to
schedule on a non-HD channel, even though the user wanted HD purely
because the non-HD broadcast was found first and the channels were not
merged.
So we now check our recording list to determine if the event is better
than the already scheduled event. If so, the existing recording event
is replaced.
For our criteria, "better" is defined in the function
dvr_is_better_recording_timeslot, and has a variety of criteria such
as "matches service filter", "earlier start", and "has more services"
(so more likely to be able to failover if there is a problem). If
other criteria are equal, then we use the channel with the lowest
channel number since Europe EPG has lower channel numbers for
'better' channels.
When determining if an autorec can be scheduled in a better timeslot,
we must only check against other autorecs and not a manually scheduled
entry since the user might schedule a recording at a later date
specifically to avoid conflicts.
This is achieved by replacing the old scheduled recording with a new
scheduled recording. A new log message indicates when this occurs.
Performance: Initial testing suggests that this rescheduling can occur
between zero and two times per programme (when there is an initial
schedule on +1, then a reschedule on non-timeshift SD, then final
schedule on HD). However, it should not add significant runtime
overhead for most people.