Project

General

Profile

HTSP - how to delete a DVR entry given an eventId?

Added by Sébastien Aubry almost 9 years ago

Hi,
When parsing the EPG using the Python API to HTSP, I get a lot of events.
Based of different criteria, I would like to add or to delete some DVR entries (like explained in #3417) using these events.
I can add them, but I do not see how to delete them, i.e. how to make the link between eventId and dvrEntryId?
Thanks

Currently my code (in progress) is something like:

#!/usr/bin/env python

import collections
import htsp

seen = collections.deque()
client = htsp.HTSPClient(('192.168.0.2', 9982))
client.getEvents()
events = client.recv()['events']
for event in events:
  if event.get("starRating") >= 60:
    print(event["title"])
    episodeId = event.get("episodeId")
    if episodeId:
      if episodeId in seen:
        print("Deleting")
        client.deleteDvrEntry({"eventId":event["eventId"]})
        print(client.recv())
      else:
        seen.append(episodeId)
        client.addDvrEntry({"eventId":event["eventId"]})
        print(client.recv())

Replies (4)

RE: HTSP - how to delete a DVR entry given an eventId? - Added by Ulrich Buck almost 9 years ago

The addDvrEntry method will return the "ID of created DVR entry" (different from the eventId) which you use in the deleteDvrEntry method.

You might need to keep a list of eventId and dvrEntryId.

RE: HTSP - how to delete a DVR entry given an eventId? - Added by Sébastien Aubry almost 9 years ago

Thank you,
But if the DVR entry was created by another means (e.g. web interface), can you retrieve its ID in order to delete it if needed?
Don't we miss a method to get all the DVR entries, which would also give the associated eventIds?

Regards

RE: HTSP - how to delete a DVR entry given an eventId? - Added by Ulrich Buck almost 9 years ago

You can use the enableAsyncMetadata method to get all DVR entries. For example like this

  htsp.enableAsyncMetadata(args)
  # Process messages
  while True:
    msg = htsp.recv()
    if 'method' in msg:
      if msg['method'] == 'dvrEntryAdd':
        log.info(msg, pretty=True)
      elif msg['method'] == 'initialSyncCompleted':
        break
  log.info('initialSync completed')

The received messages will include the eventId and the DVR entry ID.

Refer to https://github.com/tvheadend/tvheadend/blob/master/support/htspmon for a sample script.

    (1-4/4)