forked from luizoti/script.library.integration.tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context2.py
59 lines (49 loc) · 1.58 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
49
50
51
52
53
54
55
56
57
58
59
# -*- 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
import xbmcgui
from resources.lib.misc import notification
from resources.lib.misc import getstring
from resources.lib.database import Database
from resources.lib.progressbar import ProgressBar
from resources.lib.menus.synced import SyncedMenu
from resources.lib.utils import entrypoint
@entrypoint
def main():
"""Main entrypoint for context menu item."""
sync_type = False
file = xbmc.getInfoLabel('Container.FolderPath')
label = xbmc.getInfoLabel('Container.FolderName')
STR_CHOOSE_CONTENT_TYPE = getstring(32164)
OPTIONS = {
32160: 'all_items',
32161: 'movie',
32162: 'tvshow',
32167: 'filter',
32157: 'cancel'
}
selection = xbmcgui.Dialog().select(
heading=STR_CHOOSE_CONTENT_TYPE,
list=[getstring(x) for x in OPTIONS],
useDetails=False,
preselect=False
)
if selection == 'cancel':
STR_NOT_SELECTED = getstring(32158)
notification(STR_NOT_SELECTED, 4000)
else:
sync_type = OPTIONS[list(OPTIONS.keys())[selection]]
if sync_type:
syncedmenu = SyncedMenu(
database=Database(),
progressdialog=ProgressBar()
)
syncedmenu.add_all_items_in_directory(
sync_type,
label,
file
)
if __name__ == '__main__':
main()