Skip to content

Commit

Permalink
Ask when adding media to the library
Browse files Browse the repository at this point in the history
  • Loading branch information
steeve committed Feb 20, 2014
1 parent 3e5d0c7 commit dc26bbf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions resources/site-packages/xbmctorrent/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ def _rescan_library(path=None):
def library_add(content_type):
import os
import xbmc
import xbmcgui
from xbmctorrent.magnet import ensure_magnet, display_name
from xbmctorrent.utils import get_show_info_from_name
from urllib import quote_plus, unquote

play_url = "plugin://plugin.video.xbmctorrent/play/"
for name, entry in LIBRARY_PATHS.items():
if entry["strContent"] == content_type:

if not xbmcgui.Dialog().yesno("Add to %s" % name, "Add \"%s\" to %s ?" % (plugin.request.args_dict["label"], name), ""):
return

real_path = xbmc.translatePath(entry["strPath"])
uri = unquote(plugin.request.args_dict["href"].replace(play_url, ""))
magnet_uri = ensure_magnet(uri)
Expand Down Expand Up @@ -145,8 +150,8 @@ def _fn(*a, **kwds):
for item in items:
if item.get("is_playable"):
item.setdefault("context_menu", []).extend([
("Add to Movies", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="movies", href=item["path"])),
("Add to TV", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="tvshows", href=item["path"])),
("Add to Movies", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="movies", label=item["label"], href=item["path"])),
("Add to TV", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="tvshows", label=item["label"], href=item["path"])),
])
yield item
return _fn

0 comments on commit dc26bbf

Please sign in to comment.