Play images and video from Synology PhotoStation server

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # coding: utf-8
  2. """
  3. Functions for Kodi plugins
  4. """
  5. import sys
  6. SORT_METHOD_ALBUM = 13
  7. SORT_METHOD_ALBUM_IGNORE_THE = 14
  8. SORT_METHOD_ARTIST = 11
  9. SORT_METHOD_ARTIST_IGNORE_THE = 12
  10. SORT_METHOD_BITRATE = 40
  11. SORT_METHOD_CHANNEL = 38
  12. SORT_METHOD_COUNTRY = 16
  13. SORT_METHOD_DATE = 3
  14. SORT_METHOD_DATEADDED = 19
  15. SORT_METHOD_DATE_TAKEN = 41
  16. SORT_METHOD_DRIVE_TYPE = 6
  17. SORT_METHOD_DURATION = 8
  18. SORT_METHOD_EPISODE = 22
  19. SORT_METHOD_FILE = 5
  20. SORT_METHOD_FULLPATH = 32
  21. SORT_METHOD_GENRE = 15
  22. SORT_METHOD_LABEL = 1
  23. SORT_METHOD_LABEL_IGNORE_FOLDERS = 33
  24. SORT_METHOD_LABEL_IGNORE_THE = 2
  25. SORT_METHOD_LASTPLAYED = 34
  26. SORT_METHOD_LISTENERS = 36
  27. SORT_METHOD_MPAA_RATING = 28
  28. SORT_METHOD_NONE = 0
  29. SORT_METHOD_PLAYCOUNT = 35
  30. SORT_METHOD_PLAYLIST_ORDER = 21
  31. SORT_METHOD_PRODUCTIONCODE = 26
  32. SORT_METHOD_PROGRAM_COUNT = 20
  33. SORT_METHOD_SIZE = 4
  34. SORT_METHOD_SONG_RATING = 27
  35. SORT_METHOD_STUDIO = 30
  36. SORT_METHOD_STUDIO_IGNORE_THE = 31
  37. SORT_METHOD_TITLE = 9
  38. SORT_METHOD_TITLE_IGNORE_THE = 10
  39. SORT_METHOD_TRACKNUM = 7
  40. SORT_METHOD_UNSORTED = 37
  41. SORT_METHOD_VIDEO_RATING = 18
  42. SORT_METHOD_VIDEO_RUNTIME = 29
  43. SORT_METHOD_VIDEO_SORT_TITLE = 24
  44. SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE = 25
  45. SORT_METHOD_VIDEO_TITLE = 23
  46. SORT_METHOD_VIDEO_YEAR = 17
  47. def player(url, title = "", suburl= "",headers={}):
  48. from subprocess import call
  49. if not url:
  50. return
  51. cmd1 = [r"c:\Program Files\VideoLAN\VLC\vlc.exe",url,
  52. "--meta-title",title.decode("utf8").encode(sys.getfilesystemencoding()),
  53. "--http-user-agent","Enigma2"
  54. ]
  55. # gst-launch-1.0 -v souphttpsrc ssl-strict=false proxy=127.0.0.1:8888 extra-headers="Origin:adadadasd" location="http://bitdash-a.akamaihd.net/content/sintel/sintel.mpd" ! decodebin! autovideosink
  56. cmd2 = [
  57. r"C:\gstreamer\1.0\x86_64\bin\gst-launch-1.0","-v",
  58. "playbin", 'uri="%s"'%url,
  59. #"souphttpsrc", "ssl-strict=false",
  60. #"proxy=127.0.0.1:8888",
  61. #'location="%s"'%url,
  62. #'!decodebin!autovideosink'
  63. ]
  64. cmd3 = ["ffplay.exe",url]
  65. cmd = cmd1 if url.startswith("https") else cmd2
  66. ret = call(cmd3)
  67. #if ret:
  68. #a = raw_input("*** Error, continue")
  69. return
  70. def setResolvedUrl(handle, succeeded, listitem):
  71. """Callback function to tell XBMC that the file plugin has been resolved to a url
  72. :param handle: integer - handle the plugin was started with.
  73. :param succeeded: bool - True=script completed successfully/False=Script did not.
  74. :param listitem: ListItem - item the file plugin resolved to for playback.
  75. Example::
  76. xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
  77. """
  78. url = listitem.path
  79. title = listitem.label
  80. player(url,title)
  81. pass