Kodi Community Forum
Pictures database and library mode; scan EXIF and IPTC metadata tags into a SQL db - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Pictures database and library mode; scan EXIF and IPTC metadata tags into a SQL db (/showthread.php?tid=80845)

Pages: 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


- fiveisalive - 2010-10-23

solexalex Wrote:I already coded something for that. It is fixed right now, but the only things I have to do is to put this into settings somehow
Include Weekday is not a very good idea because python include only english weekday. The same is for months. So if I want to use fullnameweekday and fullnamemonth, I have to put all of these inside the string.xml for translations, and put the format of the date into settings (or even inside strings.xml it is doable as well)
This is already in the svn if you want to test by your own. The format for the 'by dates' view is :
for years.... YYYY
for months : MM/YYYY
for days : DD/MM/YYYY
(French numerical dates notations)
So it is right now only to show it is doable, but not yet ported to be translated (just a matter of some easy code change)

Ultimately I think it would be good to include the weekday, because of the ease of identifying dates for users (most often easier to remember more recent dates by the day of the week). I am happy to work on the translations etc. if necessary. There should be a way around the language issue as you suggest using the strings.xml.


- solexalex - 2010-10-23

was planning to go to bed when I saw your message....
So I re-opened my python editor and did it... It works Smile
I commit this in a few seconds


- fiveisalive - 2010-10-24

solexalex Wrote:hum hum...
You speak about "Please scan now!", I think it is "Perform a scan now !". Anyway, this option in the settings should not exists anymore.....
I recommend you to delete the plugin.image.mypicsdb settings folder. It seems strange that this keeps old settings...
i have to get the information if there is something to do to reset the settings from scratch...

I deleted my ~/.xbmc/userdata/addon_data/plugin.image.mypicsdb directory, but I get the same problem. I think there are some missing strings in English.xml for settings and actually for some other settings as well. I've attached a patch that fixes missing "Global search" and "Root folders" and also rewords "All the period" to a better phrasing as "All the images from".

Code:
Index: resources/language/English/strings.xml
===================================================================
--- resources/language/English/strings.xml    (revision 132)
+++ resources/language/English/strings.xml    (working copy)
@@ -12,7 +12,10 @@
    
     <string id="30050">pics</string>
    
-    <string id="30100">All the period %s (%s pics)</string>
+    <string id="30098">Global search</string>
+    <string id="30099">Root folders</string>
+    
+    <string id="30100">All images from %s (%s pics)</string>
     <string id="30101">Browse by Dates</string>
     <string id="30102">Browse by Folders</string>
     <string id="30103">Browse by keywords</string>



- fiveisalive - 2010-10-24

OK, I think I fixed the English translations and added the missing date stuff. Here's a combined patch which supercedes the previous patch, which fixes the dates for both French (leaves French dates as e.g. "Sat 10/10/2010" and English as Weekday, Month Day, Year, e.g. "Sat Oct 10, 2010":

Code:
Index: resources/language/French/strings.xml
===================================================================
--- resources/language/French/strings.xml    (revision 132)
+++ resources/language/French/strings.xml    (working copy)
@@ -7,7 +7,7 @@
     <string id="30003">%m/%Y</string>         <!-- month format -->
     <string id="30004">%Y</string>            <!-- year format -->
     <string id="30005">Lu.|Ma.|Me.|Je.|Ve.|Sa.|Di.</string>
-    <string id="30006"></string>
+    <string id="30006">janv.|fév.|mars|av.|mai|juin|juil.|août|sep.|oct.|nov.|déc.</string>

     <string id="30020">Dossier images</string>
     <string id="30021">Retirer de la base les images manquantes</string>
Index: resources/language/English/strings.xml
===================================================================
--- resources/language/English/strings.xml    (revision 132)
+++ resources/language/English/strings.xml    (working copy)
@@ -2,17 +2,31 @@
<strings>
     <string id="30000">MyPicture Database</string>
     <string id="30001">Database</string>
+    <!-- Date formats : use the date formatting you found in this : http://docs.python.org/library/time.html#time.strftime -->
+    <string id="30002">%a %b %d, %Y</string>      <!-- date format -->
+    <string id="30003">%b %Y</string>         <!-- month format -->
+    <string id="30004">%Y</string>            <!-- year format -->
+    <string id="30005">Mon|Tue|Wed|Thu|Fri|Sat|Sun</string>
+    <string id="30006">Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec</string>

     <string id="30020">Picture folder</string>
     <string id="30021">Remove from database missing pictures</string>
-    <string id="30022">Recursive scan ( all sub-folders will be scanned for pictures )</string>
-    <string id="30023">Folder to scan</string>
-    <string id="30024">Perform a scan now !</string>
+    <string id="30022">Recursive scan (all sub-folders will be scanned for pictures)</string>
+    
+    <string id="30024">Perform the scan at startup</string>
     <string id="30025">Initialize the database before scanning</string>
-    
+    <string id="30026">Use image as fanart</string>
+
     <string id="30050">pics</string>
+
+    <string id="30060">Geolocalization</string>
+    <string id="30061">Archive these images</string>
+    <string id="30062">Export these images to...</string>
+
+    <string id="30098">Global search</string>
+    <string id="30099">Root folders</string>
    
-    <string id="30100">All the period %s (%s pics)</string>
+    <string id="30100">All images from %s (%s pics)</string>
     <string id="30101">Browse by Dates</string>
     <string id="30102">Browse by Folders</string>
     <string id="30103">Browse by keywords</string>
@@ -26,9 +40,9 @@
     <string id="30111">Delete this period</string>
     <string id="30112">Rename this period</string>
     <string id="30113">From %s to %s</string>
-    <string id="30114"></string>
-    <string id="30115"></string>
-    <string id="30116"></string>
+    <string id="30114">Manually enter a date</string>
+    <string id="30115">Search for word</string>
+    <string id="30116">%s results for %s in %s</string>
    
     <string id="30150">Collections</string>
     <string id="30151">Remove from the collection</string>
@@ -41,17 +55,19 @@
     <string id="30158">Remove this collection</string>
     <string id="30159">Rename this collection</string>
     <string id="30160">Create a new collection</string>
-    
-    <string id="30201">No folders to scan is set !</string>
-    <string id="30202">Please edit plugin settings to set the picture path to scan</string>
-    <string id="30203">Path to scan :</string>
-    <string id="30204">Deleting missing folders...</string>
-    <string id="30205">Opening database :</string>
-    <string id="30206"></string>
-    <string id="30207"></string>
-    <string id="30208"></string>
-    <string id="30209"></string>
-    <string id="30210"></string>
-    <string id="30211"></string>
-    <string id="30212"></string>
+  
+    <string id="30201">Folder to scan</string>
+    <string id="30202">Browse this folder recursively</string>
+    <string id="30203">Delete entries in database if the images are not found</string>
+    <string id="30204">Folder added</string>
+    <string id="30205">Folder deleted</string>
+    <string id="30206">Perform a scan now</string>
+    <string id="30207">Ignore this folder in the database</string>
+    <string id="30208">Add a folder to the database</string>
+
+    <string id="30300">Filename</string>
+    <string id="30301">Folder</string>
+    <string id="30302">Thumbnail</string>
+    <string id="30303">Loading map...</string>
+
</strings>
Index: default.py
===================================================================
--- default.py    (revision 132)
+++ default.py    (working copy)
@@ -209,6 +209,7 @@
         #value  = "2009"|"12/2009"|"25/12/2009"
         action="showdate"
         weekdayname = __language__(30005).split("|")
+        monthname = __language__(30006).split("|")
         if self.args.period=="year":
             listperiod=MPDB.get_years()
             nextperiod="month"
@@ -224,7 +225,7 @@
             allperiod="year"
             action="showdate"
             periodformat="%Y-%m"
-            displaydate=__language__(30003)#%m/%Y
+            displaydate=__language__(30003)#%b %Y
             thisdateformat="%Y"
             displaythisdate=__language__(30004)#%Y
         elif self.args.period=="date":
@@ -233,9 +234,9 @@
             allperiod = "month"
             action="showpics"
             periodformat="%Y-%m-%d"
-            displaydate=__language__(30002)#"%a %d/%m/%Y"
+            displaydate=__language__(30002)#"%a %b %d, %Y"
             thisdateformat="%Y-%m"
-            displaythisdate=__language__(30003)#"%m/%Y"
+            displaythisdate=__language__(30003)#"%b %Y"
         else:
             listperiod=[]
             nextperiod=None
@@ -256,8 +257,9 @@
                         context = [(__language__(30152),"XBMC.RunPlugin(\"%s?action='addfolder'&method='date'&period='%s'&value='%s'&viewmode='scan'\")"%(sys.argv[0],nextperiod,period))]
                     else:
                         context = [(__language__(30152),"XBMC.RunPlugin(\"%s?action='addfolder'&method='date'&period='%s'&value='%s'&viewmode='scan'\")"%(sys.argv[0],self.args.period,period))]
-                
-                    self.addDir(name      = "%s (%s %s)"%(time.strftime(displaydate.replace("%a",weekdayname[time.strptime(period,periodformat).tm_wday]).encode("utf8"),time.strptime(period,periodformat)).decode("utf8"),MPDB.countPeriod(self.args.period,period),__language__(30050).encode("utf8")), #libellé
+                    displaydate.replace("%a",weekdayname[time.strptime(period,periodformat).tm_wday])
+                    displaydate.replace("%b",monthname[time.strptime(period,periodformat).tm_mon - 1])
+                    self.addDir(name      = "%s (%s %s)"%(time.strftime(displaydate.encode("utf8"),time.strptime(period,periodformat)).decode("utf8"),MPDB.countPeriod(self.args.period,period),__language__(30050).encode("utf8")), #libellé
                                 params    = [("method","date"),("period",nextperiod),("value",period),("viewmode","view")],#paramètres
                                 action    = action,#action
                                 iconimage = os.path.join(PIC_PATH,"dates.png"),#icone



- solexalex - 2010-10-24

shame on me...
I thank you for this patch, but... Sad I don't know how to apply.
I use tortoise svn , not git. Can you tell me ?


- solexalex - 2010-10-24

oK I found how to use the patch, but, it may be because of the copy past I made from the forum, but an error occured on the default.py file. So the patch can't be applied.

So I made the changes by hand, and add some more stuff. You can now use any of the short day name ; long day name ; short month name ; long month name

As for the strings.xml in english, I will not maintain it till my next public update. When I will be close to this release, I will bloc all new strings needed and so every one could translate the strings.


- fiveisalive - 2010-10-24

solexalex Wrote:oK I found how to use the patch, but, it may be because of the copy past I made from the forum, but an error occured on the default.py file. So the patch can't be applied.

Probably best for me to e-mail or message you the patch file, cut and paste from the forum may introduce errors.

Quote:So I made the changes by hand, and add some more stuff. You can now use any of the short day name ; long day name ; short month name ; long month name

As for the strings.xml in english, I will not maintain it till my next public update. When I will be close to this release, I will bloc all new strings needed and so every one could translate the strings.

I think I translated all the strings currently in French/strings.xml, so that part should be ready to go, currently they'll be missing items in the settings dialog and elsewhere if that part of the patch isn't applied. I didn't yet see an update with SVN?


- solexalex - 2010-10-24

no sorry not yet. I planned a svn update as soon as I made ready to translate all the strings actually used in the plugin. I hope tonight.


- fiveisalive - 2010-10-25

OK, now I'm having a new problem with the file scanner. I just copied some files to the "root folder" I'm monitoring, the first of which is P1080277.JPG. On the first scan, it adds it, showing "15300 files scanned 23 added 0 deleted", but none of the 23 pics appear for this specific date. If I leave the plugin and re-enter, it seems to keep readding it (i.e. keeps saying it added 23 pics, even though they should already be in the database). On checking the log file, I see this when it attempts to add the file to the database, so there seems to be some issue actually adding the file, but there is no Python traceback.

Code:
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> >>> DB_file_insert ...
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> P1080277.JPG
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> exceptions.Exception - table files has no column named DateAdded
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> INSERT INTO files('DateAdded','Thumb','strFilename','Image Model','Image Orientation','EXIF DateTimeOriginal','UseIt','Image DateTime','sha','EXIF DateTimeDigitized','EXIF ExifImageWidth','idFolder','EXIF SceneCaptureType','strPath') values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >>

These pics are from the exact same digital camera that all the photos in the db are from and I've had no trouble with the plugin recognizing pics that I've taken in the imports for the last few days.


- fiveisalive - 2010-10-25

fiveisalive Wrote:OK, now I'm having a new problem with the file scanner. I just copied some files to the "root folder" I'm monitoring, the first of which is P1080277.JPG. On the first scan, it adds it, showing "15300 files scanned 23 added 0 deleted", but none of the 23 pics appear for this specific date. If I leave the plugin and re-enter, it seems to keep readding it (i.e. keeps saying it added 23 pics, even though they should already be in the database). On checking the log file, I see this when it attempts to add the file to the database, so there seems to be some issue actually adding the file, but there is no Python traceback.

Code:
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> >>> DB_file_insert ...
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> P1080277.JPG
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> exceptions.Exception - table files has no column named DateAdded
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >> INSERT INTO files('DateAdded','Thumb','strFilename','Image Model','Image Orientation','EXIF DateTimeOriginal','UseIt','Image DateTime','sha','EXIF DateTimeDigitized','EXIF ExifImageWidth','idFolder','EXIF SceneCaptureType','strPath') values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
23:47:00 T:139871303755536 M:3425423360  NOTICE: MyPicsDB >>

These pics are from the exact same digital camera that all the photos in the db are from and I've had no trouble with the plugin recognizing pics that I've taken in the imports for the last few days.

OK, I think I figured it out. The original database (before SVN r132) didn't have the DateAdded in the SQL table. I then updated to SVN r132, and the new code was trying to add this new field to the database, but it didn't exist, so it didn't add the picture at all (even though the dialog box reported that it did). At this point it should either 1) fail noisily, 2) stop trying to add the non-existent field to the database.

I deleted the database and rescanned and all is well. Perhaps a more long-term solution would be to version the database, and if new code depends on a new database schema, it could backup the old database and perform a full rescan and recreate the database, but saving the old roo path, period, collection information.


- solexalex - 2010-10-25

Yes your right. Database versionning is planned but remember the plugin still in beta. Furthermore you test -and i m glad for this- svn versions wich are often not uptodate with my dev version and sometimes not working.

As for versionning i think i will add a table wich will contain some metas such as library version and database version or something like this.
I think i will fix database format for v1. Any further database change will be for stable version.

One thing i should do anyway is to check somehow if the database is going to work for the plugin version as many users will encounter the same problem as you.


- solexalex - 2010-10-26

I added an exception class for prevent counting the pictures that can't be input in the database
I used some more strings and change some others in the strings.xml
Commited under rev.133


- fiveisalive - 2010-10-27

FrostBox Wrote:no idea, wait alex for this problem

sorry I have not used this plugin yet, I created dialogscan only

Hi FrostBox, thanks again for fixing the problem with respect to MyPicsDB. However, I think that the presence of the dialogaddonscan can cause issues for other plugins (such as the subtitles and lyrics plugins) because it loads itself and creates a "gui.py" file that overrides those plugin's gui.py.

For more details, see my post on the XBMC Subtitles thread:

http://forum.xbmc.org/showpost.php?p=633266&postcount=430

Perhaps there are some modifications you can make to your plugin to ensure that it plays nice with these other plugins?


- fiveisalive - 2010-10-27

FrostBox Wrote:no idea, wait alex for this problem

sorry I have not used this plugin yet, I created dialogscan only

fiveisalive Wrote:Hi FrostBox, thanks again for fixing the problem with respect to MyPicsDB. However, I think that the presence of the dialogaddonscan can cause issues for other plugins (such as the subtitles and lyrics plugins) because it loads itself and creates a "gui.py" file that overrides those plugin's gui.py.

For more details, see my post on the XBMC Subtitles thread:

http://forum.xbmc.org/showpost.php?p=633266&postcount=430

Perhaps there are some modifications you can make to your plugin to ensure that it plays nice with these other plugins?

I worked around it by renaming "gui.py" to "dialoggui.py" and changing the references

Code:
from gui import Window
to
Code:
from dialoggui import Window

which seemed to fix the clashing names (also deleting the gui.pyo file too).


- FrostBox - 2010-10-27

fiveisalive Wrote:I worked around it by renaming "gui.py" to "dialoggui.py" and changing the references

Code:
from gui import Window
to
Code:
from dialoggui import Window
which seemed to fix the clashing names (also deleting the gui.pyo file too).

thanks for this bug report,

fixed http://passion-xbmc.org/addons/?Page=View&ID=script.module.dialogaddonscan
and updated plugin.image.mypicsdb see revision 135

frost