The branch, dharma-pre has been updated
via d86c26e1f38a13ab124a4fc4fda60cf750fdc8bf (commit)
from acfd6fc867b6fb767b6981e3980afe8b4620abf3 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=d86c26e1f38a13ab124a4fc4fda60cf750fdc8bf
commit d86c26e1f38a13ab124a4fc4fda60cf750fdc8bf
Author: spiff <[email protected]>
Date: Sat Oct 16 11:45:09 2010 +0200
[plugin.image.iphoto] updated to version 1.0.0
diff --git a/plugin.image.iphoto/README.txt b/plugin.image.iphoto/README.txt
index a30f870..b97a2b9 100644
--- a/plugin.image.iphoto/README.txt
+++ b/plugin.image.iphoto/README.txt
@@ -38,4 +38,6 @@ If possible, patch against the most recent version at:
Known Issues
============
-* As of 2010/07/21, it's untested under Windows.
+* Sorting by date is broken and therefore disabled for now.
+ See http://trac.xbmc.org/ticket/10519
+* No support for Keywords and Faces (yet).
diff --git a/plugin.image.iphoto/addon.py b/plugin.image.iphoto/addon.py
index 47a379c..bfb70ca 100755
--- a/plugin.image.iphoto/addon.py
+++ b/plugin.image.iphoto/addon.py
@@ -8,6 +8,7 @@ __credits__ = "Anoop Menon, Nuka1195, JMarshal, jingai"
__url__ = "git://github.com/jingai/plugin.image.iphoto.git"
import sys
+import time
import os
import os.path
@@ -28,31 +29,49 @@ from resources.lib.iphoto_parser import *
db_file = xbmc.translatePath(os.path.join(addon.getAddonInfo("Profile"),
"iphoto.db"))
db = IPhotoDB(db_file)
-def list_photos_in_event(params):
- global db
+apple_epoch = 978307200
- rollid = params['rollid']
- media = db.GetMediaInRoll(rollid)
+def render_media(media):
+ sort_date = False
n = 0
- for (caption, mediapath, thumbpath, originalpath, rating) in media:
+ for (caption, mediapath, thumbpath, originalpath, rating, mediadate,
mediasize) in media:
if (not mediapath):
mediapath = originalpath
if (not thumbpath):
- thumbpath = originalpath
+ thumbpath = mediapath
if (not caption):
- caption = originalpath
+ caption = mediapath
- # < r34717 doesn't support unicode thumbnail paths
- try:
- item = gui.ListItem(caption, thumbnailImage=thumbpath)
- except:
- item = gui.ListItem(caption)
+ if caption:
+ # < r34717 doesn't support unicode thumbnail paths
+ try:
+ item = gui.ListItem(caption, thumbnailImage=thumbpath)
+ except:
+ item = gui.ListItem(caption)
- plugin.addDirectoryItem(handle = int(sys.argv[1]), url=mediapath,
listitem = item, isFolder = False)
- n += 1
+ try:
+ item_date = time.strftime("%d.%m.%Y",
time.localtime(apple_epoch + float(mediadate)))
+ #item.setInfo(type="pictures", infoLabels={ "size": mediasize,
"date": item_date })
+ #sort_date = True
+ except:
+ pass
+ plugin.addDirectoryItem(handle = int(sys.argv[1]), url = mediapath,
listitem = item, isFolder = False)
+ n += 1
+
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_UNSORTED)
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_LABEL)
+ if sort_date == True:
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_DATE)
return n
+def list_photos_in_event(params):
+ global db
+
+ rollid = params['rollid']
+ media = db.GetMediaInRoll(rollid)
+ return render_media(media)
+
def list_events(params):
global db,BASE_URL
@@ -68,6 +87,7 @@ def list_events(params):
if (not rolls):
return
+ sort_date = False
n = 0
for (rollid, name, thumbpath, rolldate, count) in rolls:
# < r34717 doesn't support unicode thumbnail paths
@@ -76,32 +96,21 @@ def list_events(params):
except:
item = gui.ListItem(name)
- item.setInfo(type="pictures", infoLabels={ "count": count })
-
- plugin.addDirectoryItem(handle = int(sys.argv[1]),
url=BASE_URL+"?action=events&rollid=%s" % (rollid), listitem = item, isFolder =
True)
- n += 1
-
- return n
-
-def render_media(media):
- n = 0
- for (caption, mediapath, thumbpath, originalpath, rating) in media:
- if (not mediapath):
- mediapath = originalpath
- if (not thumbpath):
- thumbpath = originalpath
- if (not caption):
- caption = originalpath
-
- # < r34717 doesn't support unicode thumbnail paths
try:
- item = gui.ListItem(caption, thumbnailImage=thumbpath)
+ item_date = time.strftime("%d.%m.%Y", time.localtime(apple_epoch +
float(rolldate)))
+ item.setInfo(type="pictures", infoLabels={ "date": item_date })
+ sort_date = True
except:
- item = gui.ListItem(caption)
+ pass
- plugin.addDirectoryItem(handle = int(sys.argv[1]), url=mediapath,
listitem = item, isFolder = False)
+ item.setInfo(type="pictures", infoLabels={ "count": count })
+ plugin.addDirectoryItem(handle = int(sys.argv[1]),
url=BASE_URL+"?action=events&rollid=%s" % (rollid), listitem = item, isFolder =
True)
n += 1
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_UNSORTED)
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_LABEL)
+ if sort_date == True:
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_DATE)
return n
def list_photos_in_album(params):
@@ -127,13 +136,17 @@ def list_albums(params):
return
n = 0
- for (albumid, name) in albums:
+ for (albumid, name, count) in albums:
if name == "Photos":
continue
+
item = gui.ListItem(name)
+ item.setInfo(type="pictures", infoLabels={ "count": count })
plugin.addDirectoryItem(handle = int(sys.argv[1]),
url=BASE_URL+"?action=albums&albumid=%s" % (albumid), listitem = item, isFolder
= True)
n += 1
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_UNSORTED)
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_LABEL)
return n
def list_photos_with_rating(params):
@@ -161,6 +174,8 @@ def list_ratings(params):
plugin.addDirectoryItem(handle = int(sys.argv[1]),
url=BASE_URL+"?action=ratings&rating=%d" % (a), listitem = item, isFolder =
True)
n += 1
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_UNSORTED)
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_LABEL)
return n
def progress_callback(progress_dialog, nphotos, ntotal):
@@ -175,16 +190,18 @@ def progress_callback(progress_dialog, nphotos, ntotal):
return nphotos
def import_library(xmlfile):
- global db,db_file
+ global db_file
db_tmp_file = db_file + ".tmp"
db_tmp = IPhotoDB(db_tmp_file)
db_tmp.ResetDB()
+ # always ignore Books and currently selected album
album_ign = []
album_ign.append("Book")
album_ign.append("Selected Event Album")
+ # ignore albums published to MobileMe if configured to do so
album_ign_publ = addon.getSetting('album_ignore_published')
if (album_ign_publ == ""):
addon.setSetting('album_ignore_published', 'true')
@@ -192,6 +209,7 @@ def import_library(xmlfile):
if (album_ign_publ == "true"):
album_ign.append("Published")
+ # ignore flagged albums if configured to do so
album_ign_flagged = addon.getSetting('album_ignore_flagged')
if (album_ign_flagged == ""):
addon.setSetting('album_ignore_flagged', 'true')
@@ -204,36 +222,48 @@ def import_library(xmlfile):
progress_dialog.create(addon.getLocalizedString(30210))
except:
print traceback.print_exc()
- os.remove(db_file_tmp)
- return
-
- iparser = IPhotoParser(xmlfile, db_tmp.AddAlbumNew, album_ign,
db_tmp.AddRollNew, db_tmp.AddKeywordNew, db_tmp.AddMediaNew, progress_callback,
progress_dialog)
-
- progress_dialog.update(0, addon.getLocalizedString(30212))
- try:
- iparser.Parse()
- db_tmp.UpdateLastImport()
- except:
- print traceback.print_exc()
else:
- if (not progress_dialog.iscanceled()):
- try:
- os.rename(db_tmp_file, db_file)
- db = db_tmp
- except:
- print traceback.print_exc()
+ iparser = IPhotoParser(xmlfile, db_tmp.AddAlbumNew, album_ign,
db_tmp.AddRollNew, db_tmp.AddKeywordNew, db_tmp.AddMediaNew, progress_callback,
progress_dialog)
- try:
- os.remove(db_tmp_file)
- except:
- pass
+ progress_dialog.update(0, addon.getLocalizedString(30212))
+ try:
+ iparser.Parse()
+ db_tmp.UpdateLastImport()
+ except:
+ print traceback.print_exc()
+ else:
+ if (not progress_dialog.iscanceled()):
+ try:
+ os.rename(db_tmp_file, db_file)
+ except:
+ # windows doesn't allow in-place rename
+ remove_tries = 3
+ while remove_tries and os.path.isfile(db_file):
+ try:
+ os.remove(db_file)
+ except:
+ remove_tries -= 1
+ xbmc.sleep(1000)
+
+ try:
+ os.rename(db_tmp_file, db_file)
+ except:
+ print traceback.print_exc()
progress_dialog.close()
+ del db_tmp
+ remove_tries = 3
+ while remove_tries and os.path.isfile(db_tmp_file):
+ try:
+ os.remove(db_tmp_file)
+ except:
+ remove_tries -= 1
+ xbmc.sleep(1000)
+
def get_params(paramstring):
params = {}
- paramstring = to_unicode(paramstring)
- paramstring = paramstring.strip()
+ paramstring = str(paramstring).strip()
paramstring = paramstring.lstrip("?")
if (not paramstring):
return params
@@ -241,9 +271,12 @@ def get_params(paramstring):
for param in paramlist:
(k,v) = param.split("=")
params[k] = v
- print to_str(params)
+ print params
return params
+def add_import_lib_context_item(item):
+ item.addContextMenuItems([(addon.getLocalizedString(30213),
"XBMC.RunPlugin(\""+BASE_URL+"?action=rescan\")",)])
+
if (__name__ == "__main__"):
xmlfile = addon.getSetting('albumdata_xml_path')
if (xmlfile == ""):
@@ -258,18 +291,30 @@ if (__name__ == "__main__"):
try:
item = gui.ListItem(addon.getLocalizedString(30100),
thumbnailImage=ICONS_PATH+"/events.png")
item.setInfo("Picture", { "Title": "Events" })
+ add_import_lib_context_item(item)
plugin.addDirectoryItem(int(sys.argv[1]),
BASE_URL+"?action=events", item, True)
+
item = gui.ListItem(addon.getLocalizedString(30101),
thumbnailImage=ICONS_PATH+"/albums.png")
item.setInfo("Picture", { "Title": "Albums" })
+ add_import_lib_context_item(item)
plugin.addDirectoryItem(int(sys.argv[1]),
BASE_URL+"?action=albums", item, True)
+
item = gui.ListItem(addon.getLocalizedString(30102),
thumbnailImage=ICONS_PATH+"/star.png")
item.setInfo("Picture", { "Title": "Ratings" })
+ add_import_lib_context_item(item)
plugin.addDirectoryItem(int(sys.argv[1]),
BASE_URL+"?action=ratings", item, True)
- item = gui.ListItem(addon.getLocalizedString(30103),
thumbnailImage=PLUGIN_PATH+"/icon.png")
- plugin.addDirectoryItem(int(sys.argv[1]),
BASE_URL+"?action=rescan", item, False)
+
+ hide_import_lib = addon.getSetting('hide_import_lib')
+ if (hide_import_lib == ""):
+ addon.setSetting('hide_import_lib', 'false')
+ hide_import_lib = "false"
+ if (hide_import_lib == "false"):
+ item = gui.ListItem(addon.getLocalizedString(30103),
thumbnailImage=PLUGIN_PATH+"/icon.png")
+ plugin.addDirectoryItem(int(sys.argv[1]),
BASE_URL+"?action=rescan", item, False)
except:
plugin.endOfDirectory(int(sys.argv[1]), False)
else:
+ plugin.addSortMethod(int(sys.argv[1]), plugin.SORT_METHOD_NONE)
plugin.endOfDirectory(int(sys.argv[1]), True)
# automatically update library if desired
@@ -295,6 +340,7 @@ if (__name__ == "__main__"):
elif (action == "ratings"):
items = list_ratings(params)
elif (action == "rescan"):
+ del db
items = import_library(xmlfile)
if (items):
diff --git a/plugin.image.iphoto/addon.xml b/plugin.image.iphoto/addon.xml
index 430f3c4..dbf355b 100644
--- a/plugin.image.iphoto/addon.xml
+++ b/plugin.image.iphoto/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.image.iphoto" name="iPhoto" version="0.9.9"
provider-name="jingai">
+<addon id="plugin.image.iphoto" name="iPhoto" version="1.0.0"
provider-name="jingai">
<requires>
<import addon="xbmc.python" version="1.0"/>
<import addon="script.module.pysqlite" version="2.5.6"/>
diff --git a/plugin.image.iphoto/changelog.txt
b/plugin.image.iphoto/changelog.txt
index 30c2f4f..b44c876 100644
--- a/plugin.image.iphoto/changelog.txt
+++ b/plugin.image.iphoto/changelog.txt
@@ -1,3 +1,10 @@
+1.0.0 - 20101015
+- Enable sort on title.
+- Fix library import on Windows.
+- Default to modified image if one exists.
+- Add option to hide Import Library in main menu.
+- Add context menu item for library update.
+
0.9.9 - 20101012
- Ignore unicode thumbnail paths if they fail to add (SVN < r34733).
diff --git a/plugin.image.iphoto/resources/language/English/strings.xml
b/plugin.image.iphoto/resources/language/English/strings.xml
index fee30e9..13f69db 100644
--- a/plugin.image.iphoto/resources/language/English/strings.xml
+++ b/plugin.image.iphoto/resources/language/English/strings.xml
@@ -5,6 +5,7 @@
<string id="30210">Importing iPhoto Library</string>
<string id="30211">Imported %d items</string>
<string id="30212">Scanning AlbumData.xml...</string>
+ <string id="30213">Import iPhoto Library</string>
<!-- Category strings -->
<string id="30100">Events</string>
@@ -17,4 +18,5 @@
<string id="30001">Ignore published (MobileMe) albums</string>
<string id="30002">Ignore 'Flagged' album</string>
<string id="30003">Auto update library</string>
+ <string id="30004">Hide Import Library item in main menu</string>
</strings>
diff --git a/plugin.image.iphoto/resources/language/Hungarian/strings.xml
b/plugin.image.iphoto/resources/language/Hungarian/strings.xml
index 4b61862..bd32aeb 100644
--- a/plugin.image.iphoto/resources/language/Hungarian/strings.xml
+++ b/plugin.image.iphoto/resources/language/Hungarian/strings.xml
@@ -5,6 +5,7 @@
<string id="30210">iPhoto könyvtár importálása</string>
<string id="30211">Importálva %d elem</string>
<string id="30212">AlbumData.xml átvizsgálása...</string>
+ <string id="30213">iPhoto könyvtár importálása</string>
<!-- Category strings -->
<string id="30100">Események</string>
diff --git a/plugin.image.iphoto/resources/language/Portuguese/strings.xml
b/plugin.image.iphoto/resources/language/Portuguese/strings.xml
index 8ea6185..246b87d 100644
--- a/plugin.image.iphoto/resources/language/Portuguese/strings.xml
+++ b/plugin.image.iphoto/resources/language/Portuguese/strings.xml
@@ -3,6 +3,7 @@
<strings>
<!-- Plugin strings -->
<string id="30200">%d estrela(s)</string>
+ <string id="30213">Importar biblioteca iPhoto</string>
<!-- Category strings -->
<string id="30100">Eventos</string>
diff --git a/plugin.image.iphoto/resources/lib/iphoto_parser.py
b/plugin.image.iphoto/resources/lib/iphoto_parser.py
index be6521d..17fbab6 100755
--- a/plugin.image.iphoto/resources/lib/iphoto_parser.py
+++ b/plugin.image.iphoto/resources/lib/iphoto_parser.py
@@ -93,6 +93,7 @@ class IPhotoDB:
aspectratio number,
rating integer,
mediadate integer,
+ mediasize integer,
mediapath varchar,
thumbpath varchar,
originalpath varchar
@@ -209,7 +210,7 @@ class IPhotoDB:
albums = []
try:
cur = self.dbconn.cursor()
- cur.execute("SELECT id,name FROM albums")
+ cur.execute("SELECT id,name,photocount FROM albums")
for tuple in cur:
albums.append(tuple)
except:
@@ -233,7 +234,7 @@ class IPhotoDB:
media = []
try:
cur = self.dbconn.cursor()
- cur.execute("""SELECT M.caption, M.mediapath, M.thumbpath,
M.originalpath, M.rating
+ cur.execute("""SELECT M.caption, M.mediapath, M.thumbpath,
M.originalpath, M.rating, M.mediadate, M.mediasize
FROM media M WHERE M.rollid = ?""", (rollid,))
for tuple in cur:
media.append(tuple)
@@ -246,7 +247,7 @@ class IPhotoDB:
media = []
try:
cur = self.dbconn.cursor()
- cur.execute("""SELECT M.caption, M.mediapath, M.thumbpath,
M.originalpath, M.rating
+ cur.execute("""SELECT M.caption, M.mediapath, M.thumbpath,
M.originalpath, M.rating, M.mediadate, M.mediasize
FROM media M WHERE M.rating = ?""", (rating,))
for tuple in cur:
media.append(tuple)
@@ -259,7 +260,7 @@ class IPhotoDB:
media = []
try:
cur = self.dbconn.cursor()
- cur.execute("""SELECT M.caption, M.mediapath, M.thumbpath,
M.originalpath, M.rating
+ cur.execute("""SELECT M.caption, M.mediapath, M.thumbpath,
M.originalpath, M.rating, M.mediadate, M.mediasize
FROM albummedia A LEFT JOIN media M ON A.mediaid=M.id
WHERE A.albumid = ?""", (albumid,))
for tuple in cur:
@@ -429,12 +430,22 @@ class IPhotoDB:
thumbpath = media['ThumbPath']
originalpath = media['OriginalPath']
+ filepath = imagepath
+ if (not filepath):
+ filepath = originalpath
+
+ try:
+ mediasize = os.path.getsize(filepath)
+ except:
+ mediasize = 0
+ pass
+
try:
self.dbconn.execute("""
INSERT INTO media (id, mediatypeid, rollid, caption, guid,
- aspectratio, rating, mediadate, mediapath,
+ aspectratio, rating, mediadate, mediasize,
mediapath,
thumbpath, originalpath)
- VALUES (?,?,?,?,?,?,?,?,?,?,?)""",
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?)""",
(mediaid,
self.GetMediaTypeId(media['MediaType'], True),
media['Roll'],
@@ -443,6 +454,7 @@ class IPhotoDB:
media['Aspect Ratio'],
media['Rating'],
int(float(media['DateAsTimerInterval'])),
+ mediasize,
imagepath,
thumbpath,
originalpath))
diff --git a/plugin.image.iphoto/resources/settings.xml
b/plugin.image.iphoto/resources/settings.xml
index dd4323d..127a016 100644
--- a/plugin.image.iphoto/resources/settings.xml
+++ b/plugin.image.iphoto/resources/settings.xml
@@ -2,6 +2,7 @@
<settings>
<setting id="albumdata_xml_path" type="file" label="30000" default=""/>
<setting id="auto_update_lib" type="bool" label="30003" default="false"/>
+ <setting id="hide_import_lib" type="bool" label="30004" default="false"/>
<setting id="album_ignore_published" type="bool" label="30001"
default="true"/>
<setting id="album_ignore_flagged" type="bool" label="30002"
default="true"/>
</settings>
-----------------------------------------------------------------------
Summary of changes:
plugin.image.iphoto/README.txt | 4 +-
plugin.image.iphoto/addon.py | 172 +++++++++++++-------
plugin.image.iphoto/addon.xml | 2 +-
plugin.image.iphoto/changelog.txt | 7 +
.../resources/language/English/strings.xml | 2 +
.../resources/language/Hungarian/strings.xml | 1 +
.../resources/language/Portuguese/strings.xml | 1 +
plugin.image.iphoto/resources/lib/iphoto_parser.py | 24 ++-
plugin.image.iphoto/resources/settings.xml | 1 +
9 files changed, 143 insertions(+), 71 deletions(-)
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons