forked from patrick-klein/script.library.integration.tool
-
Notifications
You must be signed in to change notification settings - Fork 5
/
context2.py
48 lines (40 loc) · 1.43 KB
/
context2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""This module gets called from the context menu item "Sync directory to library" (32001).
The purpose is to stage all movies/tvshows in the current directory, and update database.
"""
import xbmc
from resources.lib.database import Database
from resources.lib.gui.progressbar import ProgressBar
from resources.lib.gui.select import Select
from resources.lib.menus.synced import SyncedMenu
from resources.lib.misc import get_string, notification
from resources.lib.progressbar import ProgressBar
from resources.lib.utils import entrypoint
@entrypoint
def main():
"""Main entrypoint for context menu item."""
select_menu = Select(heading=get_string(32164), turnbold=True, back_option=32157)
select_menu.options(
{
32160: "all_items",
32161: "movie",
32162: "tvshow",
32167: "filter",
},
turnbold=False,
)
selected_option = select_menu.show(useDetails=False)
if selected_option:
_, _, selected_value = selected_option
if selected_value == "back":
notification(get_string(32158), 4000)
return
SyncedMenu(
database=Database(), progressdialog=ProgressBar()
).add_all_items_in_directory(
selected_value,
xbmc.getInfoLabel("Container.FolderName"),
xbmc.getInfoLabel("Container.FolderPath"),
)
if __name__ == "__main__":
main()