|  | @@ -5,6 +5,7 @@ from consts import *
 | 
											
												
													
														|  |  import datetime
 |  |  import datetime
 | 
											
												
													
														|  |  import pprint
 |  |  import pprint
 | 
											
												
													
														|  |  import copy
 |  |  import copy
 | 
											
												
													
														|  | 
 |  | +import urllib
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  @PLUGIN.route("/empty/", name="empty", update=False, cache=True)
 |  |  @PLUGIN.route("/empty/", name="empty", update=False, cache=True)
 | 
											
										
											
												
													
														|  | @@ -408,10 +409,7 @@ def play_episode(episode_id=0, ask_playlist=0):
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      # Main Episode
 |  |      # Main Episode
 | 
											
												
													
														|  |      episode = episode_result["data"]
 |  |      episode = episode_result["data"]
 | 
											
												
													
														|  | -    path = "http://127.0.0.1:%s/play/%s/" % (play_port, episode["id"])
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |      li = copy.copy(item)
 |  |      li = copy.copy(item)
 | 
											
												
													
														|  | -    li["path"] = path
 |  | 
 | 
											
												
													
														|  |      li["properties"] = {
 |  |      li["properties"] = {
 | 
											
												
													
														|  |          "MovieID": unicode(episode["id"])
 |  |          "MovieID": unicode(episode["id"])
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
										
											
												
													
														|  | @@ -429,16 +427,14 @@ def play_episode(episode_id=0, ask_playlist=0):
 | 
											
												
													
														|  |          else:
 |  |          else:
 | 
											
												
													
														|  |              li["info"]["tagline"] = tagline
 |  |              li["info"]["tagline"] = tagline
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    li["path"] = path = "http://127.0.0.1:%s/play/%s/%s.mkv" % (play_port, episode["id"], urllib.quote(li["label"]))
 | 
											
												
													
														|  |      li = PLUGIN._listitemify(li).as_xbmc_listitem()
 |  |      li = PLUGIN._listitemify(li).as_xbmc_listitem()
 | 
											
												
													
														|  |      playlist.add(path, li)
 |  |      playlist.add(path, li)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      # Playlist episodes
 |  |      # Playlist episodes
 | 
											
												
													
														|  |      if "next_episodes" in episode_result["data"]:
 |  |      if "next_episodes" in episode_result["data"]:
 | 
											
												
													
														|  |          for episode in episode_result["data"]["next_episodes"]:
 |  |          for episode in episode_result["data"]["next_episodes"]:
 | 
											
												
													
														|  | -            path = "http://127.0.0.1:%s/play/%s/" % (play_port, episode["id"])
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |              li = copy.copy(item)
 |  |              li = copy.copy(item)
 | 
											
												
													
														|  | -            li["path"] = path
 |  | 
 | 
											
												
													
														|  |              li["properties"] = {
 |  |              li["properties"] = {
 | 
											
												
													
														|  |                  "MovieID": unicode(episode["id"])
 |  |                  "MovieID": unicode(episode["id"])
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -456,9 +452,15 @@ def play_episode(episode_id=0, ask_playlist=0):
 | 
											
												
													
														|  |                  else:
 |  |                  else:
 | 
											
												
													
														|  |                      li["info"]["tagline"] = tagline
 |  |                      li["info"]["tagline"] = tagline
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +            li["path"] = path = "http://127.0.0.1:%s/play/%s/%s.mkv" % (play_port, episode["id"], urllib.quote(li["label"]))
 | 
											
												
													
														|  |              li = PLUGIN._listitemify(li).as_xbmc_listitem()
 |  |              li = PLUGIN._listitemify(li).as_xbmc_listitem()
 | 
											
												
													
														|  |              playlist.add(path, li)
 |  |              playlist.add(path, li)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    #ifdef DEBUG
 | 
											
												
													
														|  | 
 |  | +    for idx in range(playlist.size()):
 | 
											
												
													
														|  | 
 |  | +        output("[PLAY] %s - Item %s" % (idx, playlist[idx].getPath()))
 | 
											
												
													
														|  | 
 |  | +    #endif
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      first = playlist[0]
 |  |      first = playlist[0]
 | 
											
												
													
														|  |      if first:
 |  |      if first:
 | 
											
												
													
														|  |          episode_id = first.getProperty("MovieID")
 |  |          episode_id = first.getProperty("MovieID")
 | 
											
										
											
												
													
														|  | @@ -653,7 +655,7 @@ def account_logout():
 | 
											
												
													
														|  |      return None
 |  |      return None
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -@PLUGIN.route("/stop_playserver/", name="stop_playserver", cache=True)
 |  | 
 | 
											
												
													
														|  | 
 |  | +@PLUGIN.route("/stop_playserver/", name="stop_playserver", cache=False)
 | 
											
												
													
														|  |  def stop_playserver():
 |  |  def stop_playserver():
 | 
											
												
													
														|  |      server = get_storage("server")
 |  |      server = get_storage("server")
 | 
											
												
													
														|  |      if server is None or not ("port" in server) or server["port"] == 0:
 |  |      if server is None or not ("port" in server) or server["port"] == 0:
 | 
											
										
											
												
													
														|  | @@ -661,7 +663,7 @@ def stop_playserver():
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      else:
 |  |      else:
 | 
											
												
													
														|  |          try:
 |  |          try:
 | 
											
												
													
														|  | -            client = socket.create_connection(("127.0.0.1", server["port"]), timeout=5)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            client = socket.create_connection(("127.0.0.1", server["port"]), timeout=10)
 | 
											
												
													
														|  |              if client:
 |  |              if client:
 | 
											
												
													
														|  |                  client.send("GET /exit/ HTTP/1.1")
 |  |                  client.send("GET /exit/ HTTP/1.1")
 | 
											
												
													
														|  |                  client.close()
 |  |                  client.close()
 | 
											
										
											
												
													
														|  | @@ -671,10 +673,13 @@ def stop_playserver():
 | 
											
												
													
														|  |          except:
 |  |          except:
 | 
											
												
													
														|  |              PLUGIN.notify("Playserver konnte nicht beendet werden!")
 |  |              PLUGIN.notify("Playserver konnte nicht beendet werden!")
 | 
											
												
													
														|  |              output("[SERVER] Stop error: %s" % traceback.format_exc())
 |  |              output("[SERVER] Stop error: %s" % traceback.format_exc())
 | 
											
												
													
														|  | -            __PlayServer__.__save___(0, 0)
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        finally:
 | 
											
												
													
														|  | 
 |  | +            __PlayServer__.__save__(0, 0)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      return empty()
 |  |      return empty()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  # Main
 |  |  # Main
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -921,10 +926,16 @@ def main():
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  def __run():
 |  |  def __run():
 | 
											
												
													
														|  | 
 |  | +    output("==================================== START ====================================")
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      try:
 |  |      try:
 | 
											
												
													
														|  |          PLUGIN.run()
 |  |          PLUGIN.run()
 | 
											
												
													
														|  | -    finally:
 |  | 
 | 
											
												
													
														|  | 
 |  | +    except:
 | 
											
												
													
														|  |          hide_busy_dialog()
 |  |          hide_busy_dialog()
 | 
											
												
													
														|  | 
 |  | +        raise
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    finally:
 | 
											
												
													
														|  | 
 |  | +        output("==================================== END ====================================")
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          try:
 |  |          try:
 | 
											
												
													
														|  |              os.chdir(os.path.dirname(os.path.abspath(__file__)))
 |  |              os.chdir(os.path.dirname(os.path.abspath(__file__)))
 |