2016-04-03, 00:02
After a week of reading pulling my hair out
I have this Python code that works sort of
it works I see everything I should see
but i dont see the xbmcgui.Dialog().ok(__addonname__,xx[0],xx[1],file)
and i dont see the pDialog But I think that just form running to fast
only Error im seeing in log is
09:46:57 T:140631750236160 ERROR: Misplaced [
09:46:57 T:140631750236160 ERROR: Error parsing boolean expression !String.IsEmpty($INFO[ListItem.PictureOrientatio$
09:46:57 T:140631750236160 ERROR: Misplaced [
09:46:57 T:140631750236160 ERROR: Error parsing boolean expression !String.IsEmpty($INFO[ListItem.PictureProcess])
09:47:19 T:140631750236160 ERROR: GetDirectory - Error getting plugin://script.photo.copier/
09:47:19 T:140631750236160 ERROR: CGUIMediaWindow::GetDirectory(plugin://script.photo.copier/) failed
folder setup like
script.photo.copier
addon.py
addon.xml
changelog.txt
icon.png
LICENSE.txt
/lib
__init__.py
/exifread
all its bits in there
/resources
/language
are there some more manual to read What you see is what i know about python
I have this Python code that works sort of
PHP Code:
from lib import exifread
import os, sys, time
import xbmcaddon, xbmcplugin , xbmcgui, xbmc
'''
http://mirrors.xbmc.org/docs/python-docs/16.x-jarvis/
This will copy file JPG and look at the date the photo taken
create a destion folder as for the movie file it will look at the date the file
was last Last Modified Date
StartFrom -
| Year -
| ## ### - (monthnumber monthname) eg 05 May
| the files
The reason I formated the month folder number then name only
because its in sort order by its number
'''
# Plugin constants
__addon__ = xbmcaddon.Addon()
__addonname__ = __addon__.getAddonInfo('name')
# Shared resourse
PCS_CopyTo = __addon__.getSetting('CopyTo')
PCS_MoveThem = __addon__.getSetting('MoveThem')
PCS_FindExt = __addon__.getSetting('FindExt')
PCS_Target_Mess = __addon__.getLocalizedString(30103)
PCS_LastTime = __addon__.getSetting('LastTime')
PCS_MonName = [' ','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
PCS_StartFrom = xbmcgui.Dialog().browse(0,PCS_Target_Mess,'files',PCS_FindExt.replace(',','|').lower(),True,False,PCS_LastTime)
__addon__.setSetting('LastTime',PCS_StartFrom)
PCS_Count = 0
pDialog = xbmcgui.DialogProgress()
#
def Get_exif(f):
tags = exifread.process_file(open(f, 'rb'))
ItsFile = os.path.basename(f)
#print "comment :%s" % tags['EXIF UserComment']
if tags not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
try: # try and read the EXIF DateTimeOriginal
ctime = time.strptime(str(tags['EXIF DateTimeOriginal']), '%Y:%m:%d %H:%M:%S')
This_Month = '%s %s' % (str(ctime.tm_mon),MonName[ctime.tm_mon])
return str(ctime.tm_year),This_Month,ItsFile
except KeyError: # Bugger can't read it so i get the date is was Last Modified
ctime = time.strptime(time.ctime(os.path.getmtime(f)),"%a %b %d %H:%M:%S %Y")
This_Month = '%s %s' % (str(ctime.tm_mon),MonName[ctime.tm_mon])
return str(ctime.tm_year),This_Month,ItsFile
# This is for testing am i doing it right
line1 = ">> " + PCS_StartFrom
line2 = "<< =================================== >>"
line3 = ">> " + PCS_CopyTo
PCS_YesNo = xbmcgui.Dialog().yesno(__addonname__, line1, line2, line3)
pDialog.create(__addonname__, 'Initializing script...')
if PCS_YesNo == 1:
for subdir,dirs,files in os.walk(PCS_StartFrom):
for file in files:
filename = os.path.join(subdir,file)
ext = filename[filename.rfind('.'):]
if ext.upper() in PCS_FindExt.upper():
PCS_Count += 1
xx = Get_exif(filename)
# Just Display What I got back from Get_exif() this will tell me if working
xbmcgui.Dialog().ok(__addonname__,xx[0],xx[1],file)
if not xbmcvfs.exists(os.path.join(PCS_CopyTo,xx[0],xx[1]),'/'):
success = xbmcvfs.mkdirs(os.path.join(PCS_CopyTo,xx[0],xx[1]))
#success = xbmcvfs.copy(filename,os.path.join(PCS_CopyTo,xx[0],xx[1],file))
#pDialog.update(0,"Copied .. " + file)
pDialog.close()
xbmcgui.Dialog().ok(__addonname__, __addon__.getLocalizedString(30104) + " " + str(PCS_Count))
# ===========================================================
it works I see everything I should see
but i dont see the xbmcgui.Dialog().ok(__addonname__,xx[0],xx[1],file)
and i dont see the pDialog But I think that just form running to fast
only Error im seeing in log is
09:46:57 T:140631750236160 ERROR: Misplaced [
09:46:57 T:140631750236160 ERROR: Error parsing boolean expression !String.IsEmpty($INFO[ListItem.PictureOrientatio$
09:46:57 T:140631750236160 ERROR: Misplaced [
09:46:57 T:140631750236160 ERROR: Error parsing boolean expression !String.IsEmpty($INFO[ListItem.PictureProcess])
09:47:19 T:140631750236160 ERROR: GetDirectory - Error getting plugin://script.photo.copier/
09:47:19 T:140631750236160 ERROR: CGUIMediaWindow::GetDirectory(plugin://script.photo.copier/) failed
folder setup like
script.photo.copier
addon.py
addon.xml
changelog.txt
icon.png
LICENSE.txt
/lib
__init__.py
/exifread
all its bits in there
/resources
/language
are there some more manual to read What you see is what i know about python