Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

pchtrakt

By: a guest on Feb 20th, 2013  |  syntax: None  |  size: 4.76 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     def parseResponse(self, response):
  2.         oPchStatus = PchStatus()
  3.         try:
  4.             Debug(response)
  5.             try:
  6.                                 oXml = ElementTree.fromstring(response)
  7.             except:
  8.                                 #If oXml fails do this
  9.                                 Debug("doing except")
  10.                                 response = '<?xml version="1.0" encoding="Latin-1" ?>' + response
  11.                                 oXml = ElementTree.XML(response)
  12.             Debug(response)
  13.             Debug("This should equal theDavidBox = " + oXml.tag)
  14.             if oXml.tag == "theDavidBox": # theDavidBox should be the root
  15.                        
  16. This will show in the logs as
  17.  
  18. 2013-02-20 11:20:20,644 INFO Pchtrakt START version = "0.4.23"
  19. 2013-02-20 11:20:20,904 INFO <theDavidBox><request><arg0>get_current_vod_info</arg0><module>playback</module></request><response><currentStatus>play</currentStatus><currentTime>873</currentTime><downloadSpeed>0</downloadSpeed><fullPath>/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/Le.Fabuleux.Destin.d&apos;Amélie.Poulain.(2001).avi</fullPath><lastPacketTime>0</lastPacketTime><mediatype>OTHERS</mediatype><seekEnable>true</seekEnable><title>Le.Fabuleux.Destin.d&apos;Amélie.Poulain.(2001).avi</title><totalTime>6100</totalTime></response><returnValue>0</returnValue></theDavidBox>
  20. 2013-02-20 11:20:20,943 INFO doing except
  21. 2013-02-20 11:20:20,985 INFO <?xml version="1.0" encoding="Latin-1" ?><theDavidBox><request><arg0>get_current_vod_info</arg0><module>playback</module></request><response><currentStatus>play</currentStatus><currentTime>873</currentTime><downloadSpeed>0</downloadSpeed><fullPath>/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/Le.Fabuleux.Destin.d&apos;Amélie.Poulain.(2001).avi</fullPath><lastPacketTime>0</lastPacketTime><mediatype>OTHERS</mediatype><seekEnable>true</seekEnable><title>Le.Fabuleux.Destin.d&apos;Amélie.Poulain.(2001).avi</title><totalTime>6100</totalTime></response><returnValue>0</returnValue></theDavidBox>
  22. 2013-02-20 11:20:20,987 INFO This should equal theDavidBox = theDavidBox
  23. 2013-02-20 11:20:21,034 INFO /opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/Le.Fabuleux.Destin.d'Amélie.Poulain.(2001).avi
  24. 2013-02-20 11:20:21,044 INFO File: Le.Fabuleux.Destin.d'Amélie.Poulain.(2001).avi
  25. 2013-02-20 11:20:21,094 INFO Trying search 1: http://www.imdbapi.com/?t=Le+Fabuleux+Destin+d%27Amelie+Poulain&y=2001
  26. 2013-02-20 11:20:22,073 INFO Trying search 2: http://www.deanclatworthy.com/imdb/?q=Le+Fabuleux+Destin+d%27Amelie+Poulain&year=2001
  27. 2013-02-20 11:20:22,989 INFO Trying search 3: http://www.google.com/search?q=www.imdb.com:site+Le+Fabuleux+Destin+d%27Amelie+Poulain&num=1&start=0
  28. 2013-02-20 11:20:23,421 INFO Search address = http://www.google.com/search?q=www.imdb.com:site+Le+Fabuleux+Destin+d%27Amelie+Poulain&num=1&start=0 ID = tt0211915
  29. 2013-02-20 11:20:23,425 INFO Movie : Le Fabuleux Destin d'Amelie Poulain - Year : 2001 - 15% - IMDB: tt0211915
  30. 2013-02-20 11:20:23,591 INFO trakt json url: /movie/watching/def6943c09e19dccb4df715bd4c9c6c74bc3b6d7
  31. 2013-02-20 11:20:23,593 INFO json: {"username": "USERNAME", "media_center_version": 0, "plugin_version": 0, "title": "Le Fabuleux Destin d'Amelie Poulain", "imdb_id": "tt0211915", "year": "2001", "duration": "6100", "progress": "15", "media_center_date": "10/01/2012", "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "media_center": "popcorn hour"}
  32. 2013-02-20 11:20:23,829 INFO {u'status': u'success', u'movie': {u'year': u'2001', u'tmdb_id': u'194', u'imdb_id': u'tt0211915', u'title': u'Am\xe9lie'}, u'twitter': False, u'tumblr': False, u'facebook': False, u'message': u'watching Am\xe9lie (2001)'}
  33. 2013-02-20 11:20:23,832 INFO Video playing: success - watching Amélie (2001)
  34.  
  35. So that side of this work, if i use
  36.  
  37.     def parseResponse(self, response):
  38.         oPchStatus = PchStatus()
  39.         try:
  40.             Debug(response)
  41.             oXml = ElementTree.fromstring(response)
  42.             Debug(response)
  43.             Debug("This should equal theDavidBox = " + oXml.tag)
  44.             if oXml.tag == "theDavidBox": # theDavidBox should be the root
  45.                        
  46. It does not work and i get this in the logs
  47.  
  48. 2013-02-20 12:01:25,943 INFO Pchtrakt START version = "0.4.23"
  49. 2013-02-20 12:01:26,137 INFO <theDavidBox><request><arg0>get_current_vod_info</arg0><module>playback</module></request><response><currentStatus>play</currentStatus><currentTime>89</currentTime><downloadSpeed>0</downloadSpeed><fullPath>/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/Le.Fabuleux.Destin.d&apos;Amélie.Poulain.(2001).avi</fullPath><lastPacketTime>0</lastPacketTime><mediatype>OTHERS</mediatype><seekEnable>true</seekEnable><title>Le.Fabuleux.Destin.d&apos;Amélie.Poulain.(2001).avi</title><totalTime>6100</totalTime></response><returnValue>0</returnValue></theDavidBox>
  50. 2013-02-20 12:01:26,173 INFO doing except
  51. 2013-02-20 12:01:27,724 INFO PCH status = unknown