Linux: Raspberry PI A Kodi media setup

In the lab last week , I decided to test out setting up a Raspberry Pi First gen Media center.  I must say it took some time getting everything going . Once I put the unit together and configured the application. The PI works great with Kodi 16.1 and 17.0 ..

Video Demo 

 

Comparing this to the Firestick and Android Boxes.  I would definitely go with the PI.  Here are a few reasons why 20160920_175524Full control over the appl

 

 

 

 

 

 

  1. The ability to add and remove components
  2. Works well with HDMI CEC and a wireless keyboard/mouse
  3. Not well used by non-technical individuals
  4. Does not overheat
  5. The ability to add additional storage or external drive
  6. Full control over the system and application.

The cost to setup a PI is about 65-75.00 .  A little more than your low cost Android TV Box and the Amazon Firestick.  With the PI you dont have to worry about being a Amazon or Google user.  If you go with Raspbian , you can even use the system as a Desktop computer.  Without Raspbian , you will still have terminal access to do some things.

The first gen of PI was low on memory(512MB) and CPU power. We will be setting up another use on the latest PI 3 soon.

From https://www.raspberrypi.org/products/model-b-plus/

  • Same Processor, Broadcom SoC running at 700MHz (can be overclocked)
  • Same RAM, 512MB soldered on top of the Broadcom chip
  • Same power connector, microUSB
  • Same software – be sure to run the latest Raspbian/NooBs but otherwise the overall Linux software is the same
  • First 26-pins of GPIO are the same
  • Same HDMI port
  • Audio part of the A/V jack is the same
  • Same Camera and DSI Display connecto

More GPIO. The GPIO header has grown to 40 pins, while retaining the same pinout for the first 26 pins as the Model A and B.
More USB. We now have 4 USB 2.0 ports, compared to 2 on the Model B, and better hotplug and overcurrent behaviour.
Micro SD. The old friction-fit SD card socket has been replaced with a much nicer push-push micro SD version.
Lower power consumption. By replacing linear regulators with switching ones we’ve reduced power consumption by between 0.5W and 1W.
Better audio. The audio circuit incorporates a dedicated low-noise power supply.
Neater form factor. We’ve aligned the USB connectors with the board edge, moved composite video onto the 3.5mm jack, and added four squarely-placed mounting holes.

 

Fedora 24 – Kernel upgrade 4.7.3 Virtualbox

Fedora pushed down kernel 4.7.3 to production. The sad part about this was that we received the error “A start job is running for udev wait for Complete Device….” after rebooting. After a hour of troubling shooting. The issue was related to VirtualBox 5.0 . We thought we were running the latest version of VirtualBox . But they have moved on to version 5.1.x . So after upgrading virtualbox and guest additions. The error cleared and the system booted without any issues. I dont expect to see the same issue on physical machines.

Perl: File Locking

A good function to use to force one instance of a script to run. Flock

Code snippet


use Fcntl ":flock";   # allow only one instance to run
open(my $self, "<", $0) ||
        die("001 : Cannot open myself : $!.\n");
flock($self, LOCK_EX|LOCK_NB) ||
        die("002 : Another user is running the tool.\n ");


Facebook Scraper-clear cache

If you want to control how your data looks after posting to Facebook. You will want to use the scraper debug tool.

This tool came in handy after a user wanted a particular image to show instead of a random image. The debugger allowed us to see what exactly facebook was pulling. The tool also advise us on some warning and issues we have within our codebase.

We had to edit the functions.php file and had the below snippet .Thanks to https://wordpress.org/support/topic/change-the-og-image-property


add_filter('wpseo_pre_analysis_post_content', 'mysite_opengraph_content');
function mysite_opengraph_content($val) {
return preg_replace("/<img[^>]+>/i", "", $val);
}

We also needed to edit the header.php file and add the below snippet

<meta property="og:image" content="http://example.com/hmm.jpg" />

**of course changing the values to match our website*

After making the needed changes, you can request a rescrape using the scraper tool. This can also be down via the linux command line with curl. You will need access token for this to work.

Example

curl -F access_token="<token>" -F id="cnn" -F scrape=true https://graph.facebook.com

https://developers.facebook.com/tools-and-support/

API Docs

Some of the warning we received were related to Open Graph protocol
Open Graph protocol

Computer , server issues and solutions