Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to exclude certain folders from scanning #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ v12.1.00 (future)
- Vastly improve scanning speed
- Use Gotham specific features
- Update to fanart.tv API v3
- Add option to exclude folders from scanning

v12.0.28
- Don't set simplejson module to optional
Expand Down
30 changes: 30 additions & 0 deletions lib/media_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

### import libraries
from lib.utils import log
from lib.settings import get
setting = get()

### get datalist from the unique media item
# Retrieve JSON list
Expand Down Expand Up @@ -121,6 +123,8 @@ def _media_listing(media_type):
jsonobject = simplejson.loads(json_query)
if jsonobject.has_key('result') and jsonobject['result'].has_key('tvshows'):
for item in jsonobject['result']['tvshows']:
if media_excluded(item.get('file','').encode('utf-8')): # exclude tvshow from listing if it is in excluded folder
continue
# Search for season information
json_query_season = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": {"properties": ["season", "art"], "sort": { "method": "label" }, "tvshowid":%s }, "id": 1}' %item.get('tvshowid',''))
jsonobject_season = simplejson.loads(json_query_season)
Expand Down Expand Up @@ -152,6 +156,8 @@ def _media_listing(media_type):
jsonobject = simplejson.loads(json_query)
if jsonobject.has_key('result') and jsonobject['result'].has_key('movies'):
for item in jsonobject['result']['movies']:
if media_excluded(item.get('file','').encode('utf-8')): # exclude movie from listing if file is in excluded folder
continue
imdbnumber = item.get('imdbnumber','')
if imdbnumber in ['','tt0000000','0']:
from lib.provider import tmdb # import on behalf of searching when there's no ID
Expand All @@ -177,6 +183,8 @@ def _media_listing(media_type):
jsonobject = simplejson.loads(json_query)
if jsonobject.has_key('result') and jsonobject['result'].has_key('musicvideos'):
for item in jsonobject['result']['musicvideos']:
if media_excluded(item.get('file','').encode('utf-8')): # exclude video from listing if file is in excluded folder
continue
Medialist.append({'dbid': item.get('musicvideoid',''),
'id': '',
'name': item.get('label',''),
Expand Down Expand Up @@ -212,6 +220,28 @@ def media_disctype(filename, streamdetails):
disctype = 'n/a'
return disctype

# returns True if media file meets exclusion settings
def media_excluded(filename):
global setting
excludedpath = setting['folder_exclude_path']
excludedpath2 = setting['folder_exclude_path2']
excludedpath3 = setting['folder_exclude_path3']
excludeoption = setting['folder_exclude_option']
excludeoption2 = setting['folder_exclude_option2']
excludeoption3 = setting['folder_exclude_option3']
if excludeoption:
if excludedpath != "" and filename.find(excludedpath) > -1:
return True
# only check excludeoption2, if first one was enabled as well
if excludeoption2:
if excludedpath2 != "" and filename.find(excludedpath2) > -1:
return True
#only check excludeoption3, if second one was enabled as well
if excludeoption3:
if excludedpath3 != "" and filename.find(excludedpath3) > -1:
return True
return False

def base_name(base):
base = ntpath.basename(base)
base = os.path.splitext(base)[0]
Expand Down
9 changes: 8 additions & 1 deletion lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ def get():
'musicvideo_extrathumbs': __addon__.getSetting("musicvideo_extrathumbs")== 'true',
'musicvideo_logo': __addon__.getSetting("musicvideo_logo") == 'true',
'musicvideo_clearart': __addon__.getSetting("musicvideo_clearart") == 'true',
'musicvideo_discart': __addon__.getSetting("musicvideo_discart") == 'true'}
'musicvideo_discart': __addon__.getSetting("musicvideo_discart") == 'true',

'folder_exclude_option': __addon__.getSetting("folder_exclude_option").lower() == 'true',
'folder_exclude_path': __addon__.getSetting("folder_exclude_path"),
'folder_exclude_option2': __addon__.getSetting("folder_exclude_option2").lower() == 'true',
'folder_exclude_path2': __addon__.getSetting("folder_exclude_path2"),
'folder_exclude_option3': __addon__.getSetting("folder_exclude_option3").lower() == 'true',
'folder_exclude_path3': __addon__.getSetting("folder_exclude_path3")}
return setting

def get_limit():
Expand Down
21 changes: 20 additions & 1 deletion resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ msgid "[B]Options for downloading Musicvideo artwork[/B]"
msgstr ""

#empty strings from id 32093 to 32100
#Add-on settings: Advanced settings section id=32101 to 32020
#Add-on settings: Advanced settings section id=32101 to 32120

msgctxt "#32101"
msgid "Advanced"
Expand Down Expand Up @@ -447,3 +447,22 @@ msgstr ""
msgctxt "#32192"
msgid "[I] Artwork Downloader thread on the XBMC forum. [/I]"
msgstr ""

#empty strings from id 32193 to 32210
#Add-on settings: Exclusions section id=32211 to 32220

msgctxt "#32211"
msgid "Exclusions"
msgstr ""

msgctxt "#32212"
msgid "[B]Setup folders to exclude while looking for artwork [/B]"
msgstr ""

msgctxt "#32213"
msgid "Exclude path"
msgstr ""

msgctxt "#32214"
msgid "Folder path (and subfolders)"
msgstr ""
19 changes: 19 additions & 0 deletions resources/language/German/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,22 @@ msgstr "[I]Für Fehler, Vorschläge oder alggemeine Fragen, besuche das [/I]"
msgctxt "#32192"
msgid "[I] Artwork Downloader thread on the XBMC forum. [/I]"
msgstr "[I] Artwork Downloader-Thema im XBMC-Forum (englisch). [/I]"

#empty strings from id 32193 to 32210
#Add-on settings: Exclusions section id=32211 to 32220

msgctxt "#32211"
msgid "Exclusions"
msgstr "Ausnahmen"

msgctxt "#32212"
msgid "[B]Setup folders to exclude while looking for artwork [/B]"
msgstr "[B]Pfade einrichten, die nicht durchsucht werden [/B]"

msgctxt "#32213"
msgid "Exclude path"
msgstr "Ausnahme verwenden"

msgctxt "#32214"
msgid "Folder path (and subfolders)"
msgstr "Verzeichnispfad (und Unterverzeichnisse)"
13 changes: 13 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@
<setting label="Debug" type="bool" id="debug_enabled" default="false"/>
</category>

<!-- Plugin settings: path exclusions -->
<category label="32211" id="section_exclusions">
<setting type="sep" />
<setting label="32212" type="lsep" />
<setting type="sep" />
<setting label="32213" type="bool" id="folder_exclude_option" default="false"/>
<setting label="32214" type="folder" id="folder_exclude_path" default="" source="auto" enable="eq(-1,true)" visible="eq(-1,true)"/>
<setting label="32213" type="bool" id="folder_exclude_option2" default="false" enable="eq(-2,true)" visible="eq(-2,true)"/>
<setting label="32214" type="folder" id="folder_exclude_path2" default="" source="auto" enable="eq(-1,true)" visible="eq(-1,true)"/>
<setting label="32213" type="bool" id="folder_exclude_option3" default="false" enable="eq(-2,true)" visible="eq(-2,true)"/>
<setting label="32214" type="folder" id="folder_exclude_path3" default="" source="auto" enable="eq(-1,true)" visible="eq(-1,true)"/>
</category>

<!-- Plugin settings: Info section -->
<category label="32181" id="section_info">
<setting type="sep" />
Expand Down