Github All The Things!

octocatI have continued to make little tweaks as I come across bugs and process’s that dont work properly in the Movie Database that I have built for the Raspberry Pi. Instead of create a new file and host it on Dropbox everytime I create a modification and then create a new blog detailing the change which anyone using it may or may not read I have decided to host the code on GitHub.

GitHub is a web-based hosting service for software development and basically gives me a version controlled view of what i’m up to and also the ability for you to comment on feature requests, bugs and any other issues you might run across.

If you just want the files and don’t want to comment, getting them is just as easy GitHub allows you to download them as a zip file.

Although I would appreciate it so very much if you could offer suggestions point out any bugs or even help out and comment either here or on GitHub.

I will update the links in the old how-to guides to point to the new GitHub page.

GitHub Repositories : PiMovieDB




New Functionality – Raspberry Pi Movie Database updates


New Updates! For the Raspberry Pi Movie Database

Download updates HERE (now on GitHub)

I have now added a delete function, pop-up YouTube trailers, a slightly tweaked index page to allow for bigger poster images and a few style improvements to the processing pages.

Firstly as you can see in the above image the Genre and IMDb rating information has been dropped down to the right of the poster, this enabled the poster to be a little bigger and for movies that have lots of genres to not effect the overall size of the box. At the bottom you can also see the new Trailer and ID information. The IMDb link has been dropped in this version to allow for me to hijack the database table column for a YouTube trailer code. I have found that I don’t use the IMDb link so I didn’t find it to be a loss, but it can of course be added back in if its needed. The ID# refers to its position within the database and also helps when deleting entries or adding trailer information.


Here is the new data entry screen, as per usual you can add a new movie at the top, but this time around I have added the YouTube trailer and delete functionality here as well.


To add a youtube trailer to your movie go to youtube and look it up (there is a possibility of this being automated but that’s awhile away at the moment) now get the URL code in this example the whole URL is but we only need ZVDiaYQXBVs.  Now type in the movie ID# im using ‘1’ in the above example and then the Youtube Trailer Code ‘ZVDiaYQXBVs‘ then Submit. Now in the database you will get a pop up within the browser of the trailer for the movie like this.


This new functionality is all thanks to HTML5BOX.COM and there HTML5 “lightbox”

Now the delete functionality, pretty straight forward just type in the movie ID# and click submit and its gone. It removes the entry from the database and also deletes the poster file to save space.

To install these updates just download the new files from HERE unzip them and replace the files within /var/www/movies with the new ones using a tool such as FileZilla



AirPrint with Raspberry Pi


Since Airprint is available on some HP/Canon and a few other brand printers but if you don’t have one and don’t want to buy one you might be able to enable your existing printer and CUPS.


  • For this guide I will assume that you have already setup your Pi with Raspbian.
  • Putty
  • Filezilla
  • MP620 Canon Printer (Thats what im using)


  • download bjnp files


  • sudo apt-get update
  • sudo apt-get upgrade -y
  • sudo apt-get install avahi-daemon avahi-discover libnss-mdns cups cups-pdf gutenprint pycups avahi python2
  • sudo apt-get install cups
  • sudo apt-get install python-cups
  • sudo apt-get install avahi-daemon
  • sudo usermod -aG lpadmin pi
  • sudo /etc/init.d/cups start
  • sudo /etc/init.d/avahi-daemon start
  • sudo nano /etc/cups/cupsd.conf

Now edit the config file by commenting out the below line with a # and add Port 631 to the line below

#Listen localhost:631
Port 631
Under # Restrict access.. add Allow @Local as below

# Restrict access to the server...

Order allow,deny
Allow @Local


  • and add Allow @Local again under the following headings
# Restrict access to the server...
# Restrict access to the admin pages... 
# Restrict access to configuration files...

  • sudo /etc/init.d/cups restart

Copy the downloaded bjnp files to the Pi using filezilla

  • sudo apt-get install libcups2 libcups2-dev
  • tar zxf cups-bjnp-1.2.1.tar.gz
  • cd cups-bjnp-1.2.1/
  • ./configure –prefix=/usr
  • make
  • sudo make install

Type https://XXX.XXX.X.X:631/admin into your browser and enter.



  • Select add printer
  • follow the prompts to add your printer for example a mp620’s ip might be bjnp://XXX.XXX.X.XX:8611

Within an iPad or iPhone select print and select your new printer. It will be a little slower than usual but should now work.




Build Your Own Raspberry Pi Movie Database Website



  • At least a 4gb SD Card
  • A Raspberry Pi Plugged into your Router
  • A Windows machine (Mac and Linux also work its just my example is on a windows machine)


Create SD Card

  • Connect your SD Card to the computer and run Win32 Disk Imager


  • Select the unzipped IMG file and the correct drive letter (VERY IMPORTANT, dont want to replace windows with Raspbian by accident!)
  • Select Write


  • Go pop your new Raspbian SD card into your pi.

Configure your PI

  • First thing you need to do is find the IP address of your Pi on your network
  • Find IP of PI, my router allows me to do this by logging into web manager for my web page likely to be and just type it into your web browser and then go to maintenance –> Attached Devices.


  • Connect to your pi with putty by typing in the IP address and port 22 then Open.


  • Login with the details pi/raspberry
  • Type sudo raspi-config


  • change memory_split to 16
  • Select expand_rootfs
  • Select Finish and then reboot when prompted to
  • Reconnect with putty

Run each of the following commands

  • sudo apt-get update
  • sudo apt-get upgrade -y
  • sudo apt-get install apache2 -y
  • sudo apt-get install mysql-server -y
    • When prompted to set a password in my example I have used ‘raspberry’
  • sudo apt-get install php5 -y
  • sudo apt-get install php5-mysql -y
  • sudo apt-get install libxml-parser-perl -y
  • sudo apt-get install libyaml-perl -y
  • sudo cpan
    • yes
    • yes
  • install YAML::XS
  • install XML::Simple
  • exit
  • mysql -u root -p
    • Enter your Mysql password not your “pi” password
  • USE movieCol;

Paste all of this SQL query in at once not line by line

CREATE TABLE IF NOT EXISTS `movie_collection` (
 `title` varchar(128) binary DEFAULT NULL,
 `year` varchar(128) binary DEFAULT NULL,
 `rated` varchar(128) binary DEFAULT NULL,
 `released` varchar(128) binary DEFAULT NULL,
 `genre` varchar(128) binary DEFAULT NULL,
 `director` varchar(128) binary DEFAULT NULL,
 `writer` varchar(128) binary DEFAULT NULL,
 `actors` varchar(128) binary DEFAULT NULL,
 `plot` varchar(500) binary DEFAULT NULL,
 `poster` varchar(500) binary DEFAULT NULL,
 `runtime` varchar(128) binary DEFAULT NULL,
 `rating` varchar(128) binary DEFAULT NULL,
 `votes` varchar(128) binary DEFAULT NULL,
 `imdb` varchar(128) binary DEFAULT NULL,
 `tstamp` varchar(128) binary DEFAULT NULL,
  • SHOW COLUMNS FROM movie_collection;
  • exit
  • sudo chmod 777 -R /var/www
  • sudo chown -R www-data /var/www
  • sudo chgrp -R www-data /var/www
  • Connect with Filezilla
    • Host: XXX.XXX.XX.X (IP address of your pi) Username:pi Password: raspberry port:22


  • Unzip the downloaded PHP files and move them to the /var/www
  • sudo chmod 777 -R /var/www
  • sudo chown -R www-data /var/www
  • sudo chgrp -R www-data /var/www
  • sudo reboot

Now go to http://XXX.XXX.X.XX/movies/index.php to test your new site and add a movie

and thats it!

Let me know how you go or if there are any changes you want to suggest or add.


Build Your Own Movie Database Website (Part 1)



Check out my latest update for the Raspberry Pi Movie Database!


Have you ever wanted to have a database of all of your movies that you can pull up on your Tablet/Phone/PC?

Now there are free online services that can enable this to certain degrees but using this method you can completely customise it however you wish and build any functionality that you want into it. Now what I want to show you here is how to enter the name of a movie into a form on webpage and have that webpage go and perform some searches using the OMDbAPI (Previously known as the IMdbAPI) and displaying the results in an easy to read webpage (see above screenshot as an example)

Also just a quick heads up I will break this up into 2 parts so that if you know how to setup a VM and LAMP Stack you can skip to Part 2.

Part 1. Building the LAMP Stack VM

Part 2. Configuring the Movie Database

Before we get into the nitty gritty of it it all I just want to put a shout out to Bob Belderbos at his website that served as the inspiration and the basis of alot of the code used. I have taken what Bob has on his website and expanded on the functionality a bit by adding the entry form and also the poster download functionality (that will make more sense in part 2)

First things first you need somewhere to host your brand new Movie database website. Now if you have a spare machine lying around you could use that (very minimal requirements, single core processor  256mb ram and about 4gb hdd) in this example I have used a virtualisation tool called “Virtual Box” if you are not familiar with Virtual box what it does is let you create a machine within a machine and install a new operating system on the “Virtual Machine”

Just a quick note I

Building the Server

1. If you haven’t already go to Virtualbox and download and install it.

2. You will also need to download the ISO file for a LAMP Stack (Linux, Apache, MySql, PHP)  from Turnkey

3. After the installing virtualbox create a new virtual machine. Use the settings for a Linux Other OS once the machine has been created change the network adapter settings to Bridged (if you dont do this you wont be able to see your new website on your network).


4. Now start your new Virtual Machine (VM) by double clicking on it and the prompt select your new ISO file.

5. Select “Install to Hard Disk” Select Yes or Ok to all suggested settings and configurations


6. The VM will reboot and then ask you for Passwords to various “root” accounts REMEMBER THESE (in my example my passwords for these will be “root”)

7. Turnkey gives you an option for backing up your new server to their servers and also using a DNS service (so that your websites address is instead of it is entirely up to you if you want to use this or not but in my example I wont be using them.

8. Finally it will ask you if you would like to install security updates, I suggest that you do. This process might take a few minutes, but when it finishes you should have a new screen like this


9. Now enter the top address into a web browser for example (http://192.168.0.XX) you should be directed to the Turnkey LAMP Control Panel page that looks like this.


Congratulations your new LAMP Stack is up and running

Now in part 2 we will configure the LAMP Stack and build our movie database