Remove_recording API

TVMosaic live and recorded TV products for Desktop/NAS/Raspbery Pi
Post Reply
PKMop
Posts: 5
Joined: Mon Nov 26, 2018 12:31 am

Remove_recording API

Post by PKMop » Tue Dec 31, 2019 4:37 pm

Hi,

could somebody help me on the API? I'm trying to delete a recording via VBA and MSXML2.ServerXMLHTTP60.

Am I encoding the XML parameter correctly?

Lets say I want to delete the recording 1045-16794741822203921209-1568662800

Is this the correct parameter to pass?

command=remove_recording&xml_param=%3Cremove_recording%20xmlns%3Ai%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3D%22http%3A%2F%2Fwww.dvblogic.com%22%3E%3Crecording_id%3E1045-16794741822203921209-1568662800%3C%2Frecording_id%3E%3C%2Fremove_recording%3E

Code: Select all

Dim objCON As MSXML2.ServerXMLHTTP60
Dim URL As String
Set objCON = New MSXML2.ServerXMLHTTP60
URL = "http://1.1.1.1:9270/mobile/"
objCON.Open "POST", URL, False, "USERNAME", "PASSWD"
objCON.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objCON.send "command=remove_recording&xml_param=%3Cremove_recording%20xmlns%3Ai%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3D%22http%3A%2F%2Fwww.dvblogic.com%22%3E%3Crecording_id%3E1045-16794741822203921209-1568662800%3C%2Frecording_id%3E%3C%2Fremove_recording%3E"
Debug.Print (objCON.responseText)
 
Alas, I always get this response:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <status_code>1000</status_code>
</response>
What am I doing wrong here?

TIA!

Maverickz
Posts: 55
Joined: Thu Oct 25, 2018 11:37 pm

Re: Remove_recording API

Post by Maverickz » Wed Jan 01, 2020 10:10 am

I have not used that specific command in my implementations, but try using the xml posted below. You will of course need to URL encode it first.

Code: Select all

<?xml version="1.0" encoding="utf-8" ?><remove_recording><recording_id>1045-16794741822203921209-1568662800</recording_id></remove_recording>

Maverickz
Posts: 55
Joined: Thu Oct 25, 2018 11:37 pm

Re: Remove_recording API

Post by Maverickz » Sun Jan 05, 2020 10:48 am

PKMop wrote:
Tue Dec 31, 2019 4:37 pm
Hi,

could somebody help me on the API? I'm trying to delete a recording via VBA and MSXML2.ServerXMLHTTP60.
I never heard back, did that help you?

PKMop
Posts: 5
Joined: Mon Nov 26, 2018 12:31 am

Re: Remove_recording API

Post by PKMop » Mon Jan 06, 2020 10:06 am

Hi,

sorry, could just test that out!

Thank you for your reply, but I still get a status code 1000 as a reply...

Code: Select all

command=remove_recording&xml_param=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%20%3F%3E%3Cremove_recording%3E%3Crecording_id%3E1045-16794741822203921209-1568662800%3C%2Frecording_id%3E%3C%2Fremove_recording%3E

PKMop
Posts: 5
Joined: Mon Nov 26, 2018 12:31 am

Re: Remove_recording API

Post by PKMop » Mon Jan 06, 2020 1:22 pm

Hi,

I'm deleting recordings now with remove_object. Thanks to Wireshark I checked how tvmosaic windows client is doing it, and it turns out it is not using remove_recording.

remove_object uses a different kind of id, though, which you can retrieve through get_object...

Weird...

Maybe this hack helps somebody. IMHO the tvmosaic is not very comfortable when it comes to searching, sorting, filtering and bulk deleting. Insert this code into an Excel file, save it as XLSM (with macros) and create a Sheet called GetObjects.

Also change URL, USER and PWD.

Code is crappy and q&d but worksforme.

Code: Select all

Private Const URL = "http://1.2.3.4:9270/mobile/"
Private Const USER = "username"
Private Const PWD = "password"



Sub GetRecordings()
Dim objCON As MSXML2.ServerXMLHTTP60
Dim param As String
Dim body As String
Dim objDOMResponse As New MSXML2.DOMDocument60
Dim objRecordings As New MSXML2.DOMDocument60
    Set objCON = New MSXML2.ServerXMLHTTP60


    objCON.Open "POST", URL, False, USER, PWD
    
    objCON.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    param = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
"<object_requester>" & _
    "<object_id>8F94B459-EFC0-4D91-9B29-EC3D72E92677:E44367A7-6293-4492-8C07-0E551195B99F</object_id>" & _
    "<object_type>-1</object_type>" & _
    "<item_type>-1</item_type>" & _
    "<start_position>0</start_position>" & _
    "<requested_count>-1</requested_count>" & _
    "<children_request>true</children_request>" & _
"</object_requester>"
    
    body = "command=get_object&xml_param=" & WorksheetFunction.EncodeURL(param)
    
    Debug.Print body
    objCON.send body

    objDOMResponse.LoadXML objCON.responseText
  
  
    objRecordings.LoadXML objDOMResponse.SelectNodes("/response/xml_result").Item(0).Text
    
Dim i As Long
Dim node As IXMLDOMNode
Dim Worksheet As Excel.Worksheet
    Set Worksheet = ThisWorkbook.Worksheets("GetObject")
    Worksheet.Cells.Clear
    ThisWorkbook.Worksheets("GetObject").Cells(1, 1).Value = "Delete"
    ThisWorkbook.Worksheets("GetObject").Cells(1, 2).Value = "Id"
    ThisWorkbook.Worksheets("GetObject").Cells(1, 3).Value = "Length"
    ThisWorkbook.Worksheets("GetObject").Cells(1, 4).Value = "Title"
    ThisWorkbook.Worksheets("GetObject").Cells(1, 5).Value = "Desc"

    For i = 0 To objRecordings.SelectNodes("/object/items/recorded_tv").Length - 1
        Set node = objRecordings.SelectNodes("/object/items/recorded_tv").Item(i)
        'ThisWorkbook.Worksheets("GetObject").Cells(i + 1, 1).Value = node.xml
        ThisWorkbook.Worksheets("GetObject").Cells(i + 2, 2).Value = node.SelectNodes("object_id").Item(0).Text
        ThisWorkbook.Worksheets("GetObject").Cells(i + 2, 3).Value = node.SelectNodes("size").Item(0).Text
        ThisWorkbook.Worksheets("GetObject").Cells(i + 2, 4).Value = node.SelectNodes("video_info/name").Item(0).Text
        If node.SelectNodes("video_info/short_desc").Length > 0 Then
            ThisWorkbook.Worksheets("GetObject").Cells(i + 2, 5).Value = node.SelectNodes("video_info/short_desc").Item(0).Text
        End If
        DoEvents
        Debug.Print i
    Next i
    
    'Debug.Print (objCON.responseText)

End Sub


Sub RemoveObject(objId As String)
Dim objCON As MSXML2.ServerXMLHTTP60
Dim param As String
Dim body As String
Set objCON = New MSXML2.ServerXMLHTTP60

    objCON.Open "POST", URL, False, USER, PWD
    
    objCON.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    param = "<?xml version=""1.0"" encoding=""UTF-8""?><object_remover><object_id>" & objId & "</object_id></object_remover>"
    
    body = "command=remove_object&xml_param=" & WorksheetFunction.EncodeURL(param)
    
    Debug.Print body
    objCON.send body

    Debug.Print (objCON.responseText)

End Sub

Sub DeleteMarked()
Dim Worksheet As Excel.Worksheet
Dim i As Long
    Set Worksheet = ThisWorkbook.Worksheets("GetObject")
    i = 2
    While Worksheet.Cells(i, 2) <> ""
        If (Worksheet.Cells(i, 1) = "x") Then
            RemoveObject Worksheet.Cells(i, 2)
        End If
        i = i + 1
        Debug.Print i
        DoEvents
    Wend
    Debug.Print "Done"
End Sub

Post Reply