Archive

Posts Tagged ‘Software’

Fixing corrupt Plex thumbnails

March 14, 2012 6 comments

Plex is nothing short of fantastic!
It really brings TV and Movie collections to life and makes browsing and watching media so much better than any other system I have ever used.

I did however find a problem the other day, where the thumbnails for some movies were corrupt. For example, if you imagine the image is downloaded from the top down, only half the image is showing and the rest is just grey.

At the time of writing this article, there are no other fixes published online, other than deleting your entire Plex metadata! So if you  have this problem and want a reasonably quick fix, read on…..

This fix finds the location of the Plex metadata for the movie with the corrupt thumbnail, then simply removes it and forces Plex to download a new copy of the metadata. It is fairly straightforward, but a little tricky, so please read each step carefully and use copy and past on the provided commands to avoid typos.

This fix will also work for other content such as TV shows etc with a few very obvious tweeks.

1. Open up a terminal and run this command to change to the Plex DB directory (Notice the backslashes escaping the spaces in the directory names):

cd ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases

2. Connect to the Plex DB with sqlite by running this command in the terminal window:

sqlite3 com.plexapp.plugins.library.db

You will see something like this:
iMac:Databases nik$ sqlite3 com.plexapp.plugins.library.db
SQLite version 3.6.12Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

3. Type this SQL query into the terminal window to find the GUID of the movie, this will help us find the movie metadata location:

Obviously replace ‘your movie name here’ with the movie you want to fix.

select title, guid from metadata_items where title like '%your movie name here%';

For example:

sqlite> select title, guid from metadata_items where title like '%school of rock%';

You should see the movie name and the guid, separated by a pipe (|)

My result:

The School of Rock|com.plexapp.agents.imdb://tt0332379?lang=en

4. Find the location (folder and bundle name) of the movie metadata. Close down the previous terminal window and run this command in the new window:

Obviously replacing everything in between the quotes with the guid you go when you ran your SQL query.

echo -n "com.plexapp.agents.imdb://tt0332379?lang=en" | shasum

This command will return a big long string, like this:

d616f6685a11c774befb391dc13b7c0558908acf

Which actually contains a folder name (The first character) and the name of the bundle file (The remaining characters).

Your string will be different, but the format is the same as the following:

(d) (616f6685a11c774befb391dc13b7c0558908acf)

Foldername: d
Bundle Name: 616f6685a11c774befb391dc13b7c0558908acf

5. Find the directory holding the Plex movie metadata:

In finder browse to the following directory:

~/Library/Application Support/Plex Media Server/Metadata/Movies

You will notice lots of directories named 0,1,2,3a,b,c etc.

Take the directory name (1st letter of the sha checksum) from step 4 and open that directory.

In my case this was the directory named “d”. Then find the bundle name in the folder, in my case this was “616f6685a11c774befb391dc13b7c0558908acf.bundle”

6. Move the bundle file found in step 5 to a temporary location, your desktop for example

7. Now we need to tell Plex to overwrite the cached metadata:

a) Open Plex Media Manager (Click the Plex icon at the top of the screen, then click Media Manager)

b) Find the Movie with the partially downloaded artwork, right click and choose ‘Fix Incorrect Match’

c) All you need to do in this step is select a different movie, it doesn’t matter what it is , as long as it is different. Also, make sure you remember what the correct match was!

Plex will now download the metadata for the dummy match we have just given it. Watch in Plex Media Manager for this to update.

8. Tell Plex to download the correct metadata for the Movie:

a) Find the Movie with the partially downloaded artwork in Media Manager,  right click and choose ‘Fix Incorrect Match’ again

c) Now select the correct movie, Plex will now re-download the correct metadata, including a new copy of the artwork! Replacing your corrupt thumbnail 🙂

A huge thanks to SolarPlex on the Plex forums for this article, which helped me connect to the Plex DB and find the correct metadata folder for the movie.

Here’s a link to the SolarPlex article:

http://forums2.plexapp.com/index.php/topic/31636-howto-query-data-from-plex-on-a-mac/

Share your Aperture Images with Everyone, Everywhere!

March 27, 2011 8 comments

If you want to share your Aperture images with anyone, using any device, anywhere in the world and never worry about losing your images, read on!

Like many people I have more than one type of device connected to my home network. For me it’s a Mac, a couple of Windows laptops, a Windows media server, an Xbox and a PS3.

This tutorial will guide you through the steps needed to share your Aperture albums on your home network as well as with your friends and family over the internet quickly and easily.

Assuming you already have everything in your home connected to your home network, let’s get started….

The Solution

First the images are exported from Aperture onto a Media Server. The Media Server is then used to share the images to everything else.

I personally prefer to have a separate Media Server, however this solution could also be implemented without a separate media server, by exporting images and installing all software directly onto the Mac.

Take a look at the image below which shows the overall solution.Aperture Export Sync Solution

Exporting the Images from Aperture

Images are exported from Aperture using a custom Aperture Export utility, this can be run everytime you create a new project to ensure that all your shared images are up to date. This is described in a later section of this article.

Sharing the Images with the PS3 and Xbox

Both the PS3 and the Xbox support an open protocol named DLNA (www.dlna.org). This has become the standard way to share and play media around the home. If you look for it you will see the DLNA logo on more devices than you think, including stereo systems, TVs, media software and NAS devices.

For more info including a full list of products certified to work with DLNA click the DLNA link above. DLNA also supports the streaming of movies and music to all compatible devices around your home, so after sharing your images around your network, why not share your other media too!

To share the images with a PS3/Xbox or any other DLNA compatible device I recommend Twonky Media Server (http://www.twonky.com/products/twonkyserver/) its $19.95 and worth every penny/cent whatever….

You simply install the software on your media server (Windows, Mac or Linux) and configure it to share out your files. The configuration is so simple it doesn’t warrant a step by step tutorial.

Twonky is excellent and I strongly recommend it, however feel free to check out the alternatives below.

Getting the Images onto the Cloud

“Cloud” is used generally to refer to a service someone else manages which you consume over a network, you don’t need to know how the company does what they do, simply how to use their service.

For this tutorial, our cloud is an internet based backup service that we copy all the Aperture images to.

This means two very important things:

  • All the images are backed up to the internet service. So if anything ever happened like a cooked hard drive, or fire etc all the treasured images are safe
  • The images can be accessed over the Internet from anywhere in the world

To get the images into the cloud you simply install a client and configure which folders you want to sync. It can take a while though depending on how many files you have and the speed of your internet connection! Once sync’d though it will stay in sync, so whenever you place any new files onto the media server, they will automatically be copied to the cloud.

I strongly recommend SafeSync from Trend Micro. They have an offer on at the moment which allows unlimited storage for a really low price. The client software and website are not the prettiest or easiest to use but the value for money in incredible compared to other similar providers.

SafeSync is available here: https://www.safesync.com/Pages/Welcome however you may want to check out these other providers depending on how many files you have:

Aperture Export Utility

I created this export utility using AppleScript which you can download using the link below.

Rather than publish this as compiled code, I chose to publish the source code for all the budding applescripters:

-- --------------------------------
-- ExportAllProjects_V2.scpt
-- --------------------------------

-- ------------------------------------
-- Nik Ansell (nikansell00@gmail.com)
-- March 2011
-- ------------------------------------

-- ------------------------------------------------
-- Purpose:
-- Exports all images in the Aperture DB in all projects to any folder
-- ------------------------------------------------

-- ---------------------------
-- Pre-Requisites:
-- ---------------------------

-- 1. Ensure that a folder naming policy exists named "Project Name"
-- 2. Ensure you understand what the script is doing before you run it. I will not be held accountable for any issues as a result of running this script!

-- ---------------------------
-- Features:
-- ---------------------------

-- 1. Prompts for the destination folder
-- 1.1 This can be changed by simply uncommenting the section in the script below
-- 2. Promnpt for the folder naming policy, "Project Name" is required for other features to work, please create if does not exist already
-- 2.1 This can be changed by simply uncommenting the section in the script below
-- 3. Exports all images as full size JPEGs
-- 3.1 This can be changed by changing the file naming policy section in the script below
-- 4. Sub folders are created using the image year of the first image in the project (Because "Image Year"in the Dir Naming Policy does not always work)
-- 5. Bypasses Aperture timeout errors
-- 6. Checks if the destination folder exists, if it does exist it skips if the number of images in the folder are the same as the number of images in the project
-- 6.1 Can be set to delate all images in the destination folder before exporting if needed (By choosing "Yes" when prompted
-- 7. Writes all events to a logfile at path: Desktop/Aperture_.txt
-- 8. Logs the total images found, images skipped and images exported
-- 9. Uses the original image name when exporting
-- 10. The export dir can be a network path if mounted before the script starts

-- ---------------------------
-- Known Bugs:
-- ---------------------------

-- 1. Sometimes Aperture does not return all projects, causing some projects to be skipped. This may e related to Known Bug No.2
-- Workaround: Run the script more than once, selecting "No" when prompted: "Delete files from destination folder before exporting?"

-- 2. If more than one project has the same name, all files from all projects of the same name will be placed in the same folder, or the next iteration of the project will be skipped
-- Workaround: Ensure that every project has a unique name. If you find image counts in the summary do not match the destination folders this could be your problem

-- 3. If Aperture is not able to export a file, this breaks feature 6 as the number of images will be less when exported
-- Workaround: Fix the problem and ensure that Aperture can export all images. Try exporting a project manually to test, then work through any issues you find

-- 4. If an image has no date in Aperture it may not be exported
-- Workaround: Find images without a date and choose Metadate->Adjust Date/Time, then restart Aperture

set {year:y, month:m, day:d} to (current date)
global logfilePath
set logfilePath to (path to desktop as string) & "ApertureExport_" & d & m & y & ".txt"
display dialog "Using Logfile:" & logfilePath

-- Get the path to export the files to
tell application "Finder"
set export_dir to (choose folder with prompt "Choose a folder to export into") as alias
end tell

tell application "Aperture"
activate

-- Selecting "Yes" will delete all images in a destination folder, if a destination folder already exists
set question to display dialog "Delete files from destination folder before exporting?" buttons {"Yes", "No"} default button 2
set DeleteFilesBeforeExport to button returned of question

-- Name exported files the same as the name stored in Aperture
-- Change the section below if you'd like a prompt the file naming policy
set file_policy to file naming policy "Version Name"
--set x to name of file naming policies
--choose from list x with prompt "select a file naming policy"
--set file_policy to file naming policy (item 1 of result)

-- Prompt for the folder naming policy to use
-- Change the section below to stop prompt and hard code "Project Name"
--set dir_policy to folder naming policy "Project Name"
set x to name of folder naming policies
choose from list x with prompt "Select a folder naming policy"
set dir_policy to folder naming policy (item 1 of result)

-- Export all images as Full size JPEGs
-- Change the section below to remove the prompt and hard code "Project Name"
set setting_name to "JPEG - Original Size"
--set export_setting to name of export settings
--set end of export_setting to "Master"
--choose from list export_setting with prompt "Choose a file type preset"
--set setting_name to item 1 of result

-- Initialize the log file
my WriteToLog(((current date) as string) & return, "yes")
my WriteToLog("Starting export of all Aperture images using the variables below:" & return, "no")
my WriteToLog(" export_dir: " & export_dir as string, "no")
my WriteToLog(" file_policy: Version Name", "no")
my WriteToLog(" dir_policy: Project Name", "no")
my WriteToLog(" setting_name: " & setting_name as string, "no")
my WriteToLog(" DeleteFilesBeforeExport: " & DeleteFilesBeforeExport as string, "no")
my WriteToLog(return, "no")

-- Set some vars to report the results at the end
set totalimages to 0
set totalimagesskipped to 0
set totalimagesexported to 0
set totalprojects to 0

-- Get all projects and cycle through them
set theplist to name of every project
set totalprojects to count theplist

repeat with p in theplist

set pobj to project p
set skip to "no"

tell pobj
set theimages to every image version as list
end tell

set numImagesinProject to count theimages

my WriteToLog("Found Project: " & p & " - " & numImagesinProject & " images", "no")

set totalimages to totalimages + numImagesinProject

if (numImagesinProject > 0) then

-- Get the year of the 1st image in the project
set sampleimage to item 1 of theimages
set sampleimagename to name of sampleimage
try
set sampleimageyear to value of EXIF tag "CaptureYear" of sampleimage as string
on error number -1700
set sampleimageyear to "0000"
end try
set sampleimageyear to rich text 1 thru 4 of sampleimageyear
set p to p as string
set sampleimageyear to sampleimageyear as string

-- Create the "year" folder if it doesn't exist
tell application "Finder"
if not (exists folder sampleimageyear of export_dir) then
my WriteToLog((" Creating folder: " & export_dir & sampleimageyear), "no")
make new folder at export_dir with properties {name:sampleimageyear}

end if -- if year sub folder does not exist

end tell -- tell application finder

-- Define the export dir in which to place the project folder
-- This is done to avoid two different export locations if a project spans over more than one year (E.G xmas and new year)
set export_subdir to (export_dir as string) & sampleimageyear as alias

-- Set the variable to print to log and check total exported files
set chk_dir to export_subdir & p as string

-- If folder exists, check number of images before exporting
tell application "Finder"
if (exists folder chk_dir) then
my WriteToLog(" Destination folder exists (" & chk_dir & "), counting images", "no")
-- Count images in folder
set chk_dir to chk_dir as alias
set numFilesinFolder to count of (files in folder chk_dir)
set strnumFilesinFolder to numFilesinFolder as string

if (numFilesinFolder ≥ numImagesinProject) then
set totalimagesskipped to totalimagesskipped + numImagesinProject
my WriteToLog(" Found " & strnumFilesinFolder & " files in destination folder skipping", "no")
set skip to "yes"
else
if DeleteFilesBeforeExport is "Yes" then
my WriteToLog(" Found " & strnumFilesinFolder & " Deleting files in folder before export to avoid duplicates", "no")
delete (every item of folder export_subdir)
end if -- if set to delete files in destination folder before exporting

end if -- if destination folder has more files than the project

end if -- if chk_dir exists

end tell -- tell application finder

if (skip is not equal to "yes") then
my WriteToLog((" Exporting: " & p), "no")
my WriteToLog(" To Folder: " & chk_dir, "no")
set totalimagesexported to totalimagesexported + numImagesinProject

if setting_name is "Master" then
with timeout of 3600 seconds
try
--export theimages naming files with file_policy naming folders with dir_policy to export_subdir metadata sidecar
export theimages naming files with file_policy naming folders with dir_policy to export_subdir metadata sidecar
--new to 2.0 is the ability to embed the versions' IPTC data into the master itself. change "sidecar" to "embedded" to do so.
on error number -1712 -- Timeout waiting for a confirmation message in Aperture
my WriteToLog(" Error: Timeout (Error -1712), waiting for a confirmation in Aperture, probably some images couldn't be exported", "no")
end try
end timeout
else
with timeout of 3600 seconds
try
export theimages naming folders with dir_policy using export setting setting_name to export_subdir naming files with file_policy
on error number -1712 -- Timeout waiting for a confirmation message in Aperture
my WriteToLog(" Error: Timeout (Error -1712), waiting for a confirmation in Aperture, probably some images couldn't be exported", "no")
end try
end timeout
end if -- if setting_name is "Master"

-- Check the right number of images were exported
tell application "Finder"
if (exists folder chk_dir) then
set chk_dir to chk_dir as alias
tell application "Finder"
set numFilesinFolder to count of (files in folder chk_dir)
end tell -- tell application finder
set strnumFilesinFolder to numFilesinFolder as string
my WriteToLog(" " & strnumFilesinFolder & " files found in destination folder, assuming all files exported successfully", "no")
if (numFilesinFolder < numImagesinProject) then
set diff to numImagesinProject - numFilesinFolder
set totalimagesskipped to totalimagesskipped + diff
set totalimagesexported to totalimagesexported - diff
my WriteToLog(" Error:Less files found in destination folder, try exporting manually in Aperture to troubleshoot", "no")
end if -- If less files in export folder than in project
else
-- Something went wrong with the export
my WriteToLog(" Error: Could not find destination folder, something went wrong with the export, check for previous errors", "no")
end if -- if chk_dir exists
end tell -- tell application Finder

end if -- if skip not equal to yes

end if -- if more than 0 files in project

end repeat -- repeat with every project

my WriteToLog(return & "Finished", "no")
my WriteToLog(((current date) as string) & return, "no")
my WriteToLog("Total Projects Found:" & totalprojects & return & "Total Images Found:" & totalimages & return & "Total Images Skipped:" & totalimagesskipped & return & "Total Images Exported:" & totalimagesexported, "no")
--display dialog "Total Projects Found:" & totalprojects & return & "Total Images Found:" & totalimages & return & "Total Images Skipped:" & totalimagesskipped & return & "Total Images Exported:" & totalimagesexported

end tell -- tell application Aperture

on WriteToLog(text2write, init)

set AppleScript's text item delimiters to ""

try
set fileRef to open for access logfilePath with write permission
try
if (init is "yes") then
-- Clear file contents
set eof of fileRef to 0
write text2write & return to fileRef
else
write text2write & return to fileRef starting at eof
end if -- if init value set to "yes"
end try
close access fileRef
end try
end WriteToLog

Feel free to use or modify the script in any way you choose.

However run the script at your own risk. Please do not run it unless you are comfortable with what it does! J

A few things you may want to know about this script are in the following sections.

What it does

1.     Extracts all Aperture images in your library to a folder of your choice. This can be a local or remote folder, as long as the folder is visible in the Finder application

2.     The following options are used when exporting:

Export Folder Format: <ExportFolder>/Year/ProjectName/

Export Image Format: JPEG – Original Size

3.     Additional Features:

a) Aperture timeout errors are bypassed

b) Skips the exporting of a project if the destination folder already exists, this allows the script to be re-run at any time and it will only export new projects. If you wish to override this feature select “Yes” when asked by the script.

c) Writes progress to a log file <Desktop>/Aperture_<date>.txt

How to use the export script

1.     Copy and paste the source code above into the Applescript editor and click “Compile”

2.     Read through the script and make sure you are happy with what it is doing

3.     Save the scpt file using the “Save As” in Applescript editor to any path you will remember

4.     Run the script by clicking “Run” in the Applescript editor

5.     The script will diaplay a message box with the path to the log file. Open this log file in the Apple logfile viewer as this will automatically update as the script logs it’s actions

6.     You will then be prompted for a path to export your images, make sure this path points to a location on your media server if you are using a media server to do the rest of the sharing. If not choose a location on you Mac

7.     Once the path is selected you wil be prompted to chose if you wish to delete files from the destination folder before exporting. Choose “No” if you want to only export new images

8.     You are now prompted with to choose a folder naming policy, select “Project Name”, if this doesn’t exist create one in Aperture by selecting any image, clicking “Export” then next to “Sub Folder Format” click “Edit” then click “+” to create a new folder naming policy

9.     The script will now export all the images to the chosen location, you can track the progress by opening the log file with any log file viewer

Known Bugs
  • If more than one project has the same name, all files from all projects of the same name will be placed in the same folder, or the next iteration of the project will be skipped
  • – Workaround: Ensure that every project has a unique name. If you find image counts in the log file summary do not match the destination folders this could be your problem
  • For many reasons Aperture may not be able to export an image. If you see errors in the log file, try to export the project manually then work through any issues as they arise
  • If an image has no date in Aperture it may not be exported
  • – Workaround: Find images without a date and choose Metadate->Adjust Date/Time, add the correct data then restart Aperture and kick off the script again

Please let me know how you get on by leaving a comment below.

Thanks for reading.

Dropbox – Have all your important files everywhere

October 11, 2010 1 comment


Dropbox is nothing short of fantastic!

It syncs your files/folders across all your computers, laptops and devices (iPhone, iPad, Macs, PCs, etc..) and gives you a big chunk of space free (~2GB).

I have loads of devices, work laptop, personal laptops, iMac etc etc, before drop box I was constantly copying or emailing files around from place to place making sure I didn’t overwrite the most recent copy..blah blah blah….

Now with Dropbox I simply place files I want to be available everywhere into a nominated folder, within a few seconds (or minutes if it’s a lot of data) the files are available on all devices and even on the web if I am some place with internet access and no computer.

Whener I need access to an important file on the move, I simply fire up the Dropbox app for the iPhone and get the file.

Now the best part is, anyone can get Dropbox for free, however if you get it by clicking the link below, you and I automatically get some extra space added to our accounts for free!

Check it out, I guarantee you’ll like it 🙂
Categories: Personal, Technology