# Sparki + Windows Phone

Hello,

since four month i own a Lumia 930 mobile. I was looking for an app to control my Sparkirobot. After beeing without luck finding one, i started to write my own.

It has two parts:

2. my app for Windows 8.1, Windows 10 and Windows Phone (source on GITHUB)

prerequisites:

1. Sparki has my program running and a bluetooth module attached
2. my Windows / Windows Phone App on your device

# snippet of the month: network share to onedrive

Today i wanted to sync my network share for pictures with my ondrive cloud. After searching around the net, i found this nice workaround:

OneDrive does not want any part of a network drive, but you can trick it into using a mapped network drive as its primary storage by creating a Symbolic link. Here’s the quick and dirty steps:
 Create folder on the root of your C drive (e.g. C:\Share) Create a folder inside of that called something like OneDrive (e.g. C:\Share\OneDrive) Open up the OneDrive interface, and point it to your newly created folder. Kill OneDrive Delete the Share folder inside of C:\ Open an elevated command prompt (go to Start -> Type in CMD -> Right Click and Run as Admin) Now, we'll create a symbolic link by typing in mklink /d c:\Share\ \\path\to\ where \\path\to\ is the folder containing your OneDrive folder. Restart OneDrive application and you're done! 

Sometimes on linux it will happen, that you can’t access your android devices. if you are on a shell and type “adb devices” your probalby get this error.

The most simple reason is, your user is not allowed to access this device. I found a very simple solution for devices of HTC. On a shell you create and open a new file like

Then add htc vendor ids (you will find codes for other device with google, of course)

Save this file and run following commands. These will copy your new device rules to the udev rule folder, change the permissions, restart udev device management and adb server.

If you run “adb devices” now in a shell, your should get something like:

# Python 3: retrieving podcasts with feedburner

After using PodGrab for two years it became more and more buggy. It is using a lot of native libraries of Python 2 and so it has a code base which is very complex, hard to maintain and annoying.

So that mostly the reason to program a little tool to get all my favorite podcasts.

Requirements:

1. use feedburner for easy implementation
2. Feeds sorted into subdirectories
3. check for episodes allready existing
4. managing feeds easily

At first we define Python 3 as running environment and import some iibraries. For this project we need feed feedparser, which will handle the rss-parsing-part. You might install this from pypy, but don’t do this. If you run this project with 5.1.3 of feedparser which is distributed by pypy, you will get an error. There is a patched version around google code, but you can easily use this link. Unzip it and run “python3 setup.py install”.

in step two we define two variables. With ‘FEEDSLISTFILE’ we will met requirement three. This is a simple text file containing all feedlinks you want to parse. Each url needs to be in a seperate line. It actually should be in the same directory as this script is. The second variable ‘FEEDDOWNLOADDIR’ is the directory where all files are to be downloaded.

Further on we start with our class ‘pypodcatcher’ and a method ‘getFeedsFromList’ which takes the list with our feeds. Within this method we define two lists for some information about new episodes and error handling.

Then we open our file with feed-urls and read it to a list (line 17 & 18). For every url in the list we run the method ‘loadFeeds’ which handles parsing and downloading. In line 20 you see there is a restriction defined. Only feeds which doesn’t begin with an ‘#’ are going to be parsed. It might be useful, when you want to exclude some feeds temporarily. After all feeds are parsed we can email the result to us (line 23).

Now we are going on with the ‘loadFeeds’ method. It takes the feedurl u want to parse. Parsing is done in line 24. You just need to call ‘parse’ from the feedparser library and the result ist stored in ‘feed’.

Above we have defined a directory to store all downloaded files, but storing every file in the same directory is inproper and confusing. For this reason we will create a subdirectory for every feed. to name them automatically we use the title of a feed, remove some special characters which are not allowed in a filename and use os.path.join to create a full path including our ‘FEEDDOWNLOADDIR’ (line 25).

As any filemanager python will throw an exception if you try to create a directory which allready exists. So we check if our ‘feeddldir is allready there (line 26) and create if it if not (line 31).

Next we going through the list of episodes (line 28). Each file will get an unique name which is formatted like ‘<date_published>_<episode_title>.mp3’ (Line 30 & 31). Some operating system or filesystems have limitation about the length of fullpath of a file. For this reason we cut every filename longer than 60 characters (line 33 – 36).

When the script is done with parsing, it can send us an email. If you run your script as cronjob it is very useful to get those informations. I am not going to explain this part in deep.

Finally we have a very simple script to parse rss-feeds and download podcasts. To run this just at two lines more at the end and run it.