Random Short Take #5

So it’s been over six months since I did one of these, and it’s clear that I’m literally rubbish at doing them regularly.

HTPC – Replacing The PC With macOS

The Problem

My HTPC (running Windows 7 Media Center) died a few months ago after around 5 or 6 years of service. It was a shame as I had used it as a backup for my TV recordings and also to rip optical discs to my NAS. At the time it died I was about to depart on a business trip and I couldn’t be bothered trying to work out why it died. So I gave the carcass of the machine to my nephew (who’s learning about PC hardware things) and tried to put something together using other machines in my house (namely an iMac and some other odds and sods). I’m obviously not the first person to use a Mac for these activities, but I thought it would be useful to capture my experiences.

 

Requirements

Requirements? Isn’t this just for home entertainment? Whatever, relaxation is important, and understanding your users is as well. We record a lot of free to air tv with a Fetch Mighty box and sometimes things clash. Or don’t record. “Catch-up” TV services in Australia are improving a lot, but our Netflix catalogue is nowhere near as extensive as the US one. So I like to have a backup option for TV recording. The HTPC provided that. And it had that cool Media Center extender option with the Xbox360 that was actually quite useable and meant I didn’t need a PC sitting in the lounge room.

From a movie consumption perspective, we mostly watch stuff using various clients such as AppleTV or WDTV devices, so the HTPC didn’t really impact anything there, although the way I got data from Blu-ray / DVD / HD-DVD / VCD was impacted as my iMac didn’t have a Blu-ray player attached. Okay, the SuperDrive could deal with VideoCDs, but you get my point.

So, in short, I need something that could:

  • Record free to air tv shows via a schedule;
  • Rip Blu-ray and other content to mkv containers (or similar); and
  • Grab accurate metadata for that media for use with Plex.

 

Solution?

The solution was fairly easy to put together when I thought about what I actually needed.

TV

I backed a Kickstarter for the HDHomeRun Connect some time ago and hadn’t really used the device very effectively save for the odd VLC stream on an iPad. It’s a dual-tuner device that sits on your wired network and is addressable by a few different applications over IP. The good news is that Elgato EyeTV works with both macOS and IceTV (a local TV guide provider) and also supports the HDHomeRun. I haven’t tested multiple HDHomeRun devices with the same EyeTV software and I’m not 100% convinced that this would work. I had 8 tuners on the HTPC so this is a bit of a bummer, but as it’s not the primary recording device I can live with it. The EyeTV software supports multiple export options too, so I can push shows into iTunes and have AppleTV pick them up there.

Optical Discs

I bought a USB-based Pioneer (BDR-XS06) Blu-ray drive that works with macOS, and MakeMKV is still my go to in terms of mkv ripping. It maxes out at 2x. I’m not sure if this is a macOS limitation or firmware crippling or some other thing. Now that I think about it, it’s likely the USB bus on my iMac. If anyone wants to send me a Thunderbolt dock I’m happy to try that out as an alternative. In any case a standard movie Blu-ray takes just shy of an hour to rip. It does work though. If I still need to rip HD-DVDs I can use the drive from the Xbox360 that I have laying about. What? I like to have options.

Metadata

For movie metadata I settled on MediaElch for scraping and have found it to be easy to use and reliable. Why bother with scraping metadata? It sometimes saves a bit of effort when Plex gets the match wrong.

Plex

I run Plex as the primary media server for the house (using either iPad, rasplex or AppleTV), with content being served from a number of NAS devices. It took me a while to get on board with Plex, but the ability to install the app on a 4th generation AppleTV and the portability of media has been useful at times (think plane trips on economy airlines where entertainment is an extra charge). Plex are working on a bunch of cool new features, and I’m going to try and make some time to test out the DVR functionality in the near future.

I’ve also recently started to use the auto_master file as the mechanism for mounting my SMB shares automatically on the iMac. I found User-based Login Items method was a bit flaky and shares would disappear every now and then and confuse Plex. I have three NAS devices all using a variation of the name “Multimedia” as their main share (no I didn’t really think this deployment through). As a result my iMac mounts them under Volumes as “Multimedia-1”, “Multimedia-2”, etc. This is fine, but then depending on the order they’re mounted in when the machine reboots can mess up things a bit. The process to use auto_master is fairly simple and can be found here. I’ve included an overview for your enjoyment. Firstly, fire up a terminal session and make a /mnt directory if you don’t have one already.

Last login: Mon Aug 14 05:10:12 on ttys000
imac27:~ dan$ pwd
/Users/dan
imac27:~ dan$ cd /
imac27:/ dan$ sudo mkdir mnt
Password:

You’ll then want to edit setup the auto_master file to look at auto_fs when it runs.

imac27:/ dan$ sudo nano /etc/auto_master

You should also ensure the NAS directory exists (if it doesn’t already).

imac27:/ dan$ cd /mnt
imac27:mnt dan$ sudo mkdir NAS

You can now create / modify the auto_nas file and include mount points, credentials and the shares.

imac27:/ dan$ sudo nano /etc/auto_nas

Now run your automount command.

imac27:/ dan$ sudo automount -vc
automount: /net updated
automount: /home updated
automount: /mnt/NAS updated
automount: no unmounts

Once this is done you’ll want to test that it works.

imac27:/ dan$ cd /mnt/NAS/
imac27:NAS dan$ ls
831multimedia
imac27:NAS dan$ cd 831multimedia/
-bash: cd: 831multimedia/: Too many users

Note that if you’re having issues with a “Too many users” error, it may be because you’re using a special character (like @) in your password and this is messing up the syntax for auto_master. Check this post for a resolution. Once you’ve sorted that it will look more like this.

imac27:NAS dan$ ls
412multimedia    831multimedia    omvmultimedia
imac27:NAS dan$ cd 412multimedia/
imac27:412multimedia dan$ ls
tv
imac27:412multimedia dan$ cd ..
imac27:NAS dan$ cd omvmultimedia/
imac27:omvmultimedia dan$ ls
basketball    music        music video    skateboarding    star wars    tv

It’s also a good idea to apply some permissions to that auto_nas file because you’re storing credentials in there in plain text.

imac27:/ dan$ sudo chmod 600 /etc/auto_nas
Password:

And now you can point Plex at these mount points and you shouldn’t have any problems with SMB shares disappearing randomly.

There’s just one thing though …

I’ve read a lot of reports of this functionality being broken in more recent versions of macOS. I’ve also witnessed shares disappear and get remounted with root permissions. This is obviously not ideal. There are a number of solutions floating around, including running a bash script to unmount the devices as root and then change directory as a normal user (prompting autofs to remount as that user). I found something in a forum somewhere the suggestion that I use -nosuid in my auto_master file. I did this and rebooted and the drives seem to have mounted as me rather than root. I’ll keep an eye on this and see if it continues to work or whether autofs remounts the shares as root. This would seem a non-ideal solution in a multi-user environment but that’s outside my ken at this stage.

*Update – 2017/08/20*

I ended up having problems with the auto_master method as well, and decided to create new shares on the various NAS devices with different names. These then mount as /Volumes/nas1data, /Volumes/nas2data, etc. So theoretically even if I lose the connection I can remount them manually and know that they’ll come up with a consistent path name and Plex won’t get too confused. I dragged these mounted volumes into my Login Items so that they mount every time the machine reboots. It still bites that they disappear every now and then though.

 

HTPCs Are So Last Decade

I recently threw out my RealMagic Hollywood+ XP cards. Those things were great at a time when playing DVDs on a PC was a real challenge. I remember being excited to play full screen MPEG-2 movies on my NT 4 Workstation running on a Pentium 133. Fast forward to about 8-10 years ago and it seemed everyone was running some kind of “Media Center” PC at home and consuming everything via that. Nowadays people tell me to “just stream it”. But I don’t live in a terribly bandwidth rich environment, and downloading 4GB of data from the Internet to watch a movie needs a little more prior planning than I’d like to do. So I’m still a big fan of physical discs, and still recording television shows via a PVR or via the iMac.

I still have a dream that one day I’ll happen upon the perfect user experience where I can consume whatever digital media I want in the fashion I want to. I’ve tried an awful lot of combinations in terms of backend and frontend and Plex is pretty close to doing everything I need. They don’t like ISO files though (which is justifiable, for sure). I rip most things in mkv containers now, and all of my iTunes content (well, the music at least) is pretty easy to consume, but there’re still some things that aren’t as easy to view. I still haven’t found a reliable way to consume UltraViolet content on a big screen (although I think I could do something with AirPlay). I’ve been reading a bit about various cable boxes in the US that can scan both local and streaming data for whatever you’re after and point you in the right direction. I guess this would be the way to go if you had access to reasonable bandwidth and decent content provider choices.

In any case, it’s still possible to run a HTPC the old-fashioned way with macOS.

Apple – I know too much about iPad recovery after iOS 8

So I now know too much about how to recover old files from iPad backups. I know this isn’t exactly my bread and butter, but I found the process fascinating, and thought it was worth documenting the process here. It all started when I upgraded my wife’s iPad 2 to iOS 8. Bad idea. Basically, it ran like rubbish and was pretty close to unusable. So I rolled it back, using the instructions here. Ok, so that’s cool, but it turns out I can’t restore the data from a backup because that was made with iOS 8 and wasn’t compatible with iOS 7.1.2. Okay, fine, it was probably time to clear out some apps, and all of the photos were saved on the desktop, so no big deal. Fast forward a few days, and we realise that all of her notes were on that device. Now for the fun bit. Note that I’m using a Mac. No idea what you need to do on a Windows machine, but I imagine it’s not too dissimilar.

Step 1. Recover the iPad backup from before the iOS upgrade using Time Machine. Note that you’ll need to be able to see hidden files in Finder, as the backup is stored under HOME/Library/Application Support/MobileSync/Backup and Time Machine uses Finder’s settings for file visibility. I used these instructions. Basically, fire up a terminal and type:

$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder

You’ll then see the files you need with Time Machine. When you’re finished, type:

$ defaults write com.apple.finder AppleShowAllFiles FALSE
$ killall Finder

Step 2. Now you can browse to HOME/Library/Application Support/MobileSync/Backup and recover your backup files. If you have more than one iDevice backed up, you might need to dig a bit through the files to recover the correct files. I used these instructions to locate the correct backup files. You’ll want to look for a file called “Info.plist”. In that file, you’ll see something like

<key>Device Name</key>
<string>My iPhone</string>

And from there you can restore the correct files. It will look something like this when recovered:

screen1

Step 3. Now you’ll want to go to the normal location of your iPad backups and rename your current backup to something else. Then copy the files that you recovered from Time Machine to this location.

screen2

Step 4. At this point, I followed these quite excellent instructions from Chris Taylor and used the pretty neat iPhone Backup Extractor to extract the files I needed. Once you’ve extracted the files, you’ll have something like this. Note the path of the files is iOS Files/Library/Notes.

screen3

Step 5. At this point, fire up MesaSQLite and open up the “notes.sqlite” file as per the instructions on Chris’s post. Fantastic, I’ve got access to the text from the notes. Except they have a bunch of html tags in them and are generally unformatted. Well, I’m pretty lazy, so I used the tool at Web 2.0 Generators to decode the html to formatted text for insertion into Notes.app files. And that’s it.

Conclusion. As it happens, I’ve now set this iPad up with iCloud synchronisation. *Theoretically* I won’t need to do this again. Nor should I have had to do it in the first place. But I’ve never come across an update that was quite so ugly on particular iDevices. Thanks to Apple for the learning opportunity.