12 May 2016

Ubuntu - python paramiko issue (SSH)

Today I've encountered an issue with paramiko on Ubuntu server 12.04.
Tried to run a simple python script with SSH connection and got an error below:


$ python
>>> from Exscript.protocols import SSH2
>>> conn = SSH2()
>>> conn.connect("192.68.164.1")

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/local/lib/python2.7/dist-packages/Exscript/protocols/Protocol.py", line 588, in connect

    return self._connect_hook(self.host, port)

  File "/usr/local/lib/python2.7/dist-packages/Exscript/protocols/SSH2.py", line 261, in _connect_hook

    self.client = self._paramiko_connect()

  File "/usr/local/lib/python2.7/dist-packages/Exscript/protocols/SSH2.py", line 153, in _paramiko_connect  
    t.start_client()

  File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 493, in start_client

    raise e

AttributeError: 'EntryPoint' object has no attribute 'resolve'

At this point the easiest solution is to upgrade pip and paramiko as below:
# Upgrade pip

sudo pip install --upgrade pip

#  Refresh cli cache

hash -r

# Use new pip to upgrade paramiko package

sudo pip install --upgrade paramiko

 Also you may need to upgrade setuptools.

05 May 2016

F4F fragmented video stream recording

1. Install php and required extensions
apt-get install php5
apt-get install php5-curl

1.5 It is possible, that curl will work with your webserver scripts, but not with the CLI ones. To fix that you need to update php.ini for CLI

Find curl binary  location
find / -name 'curl.so'

Find out php.ini for CLI path (usually /etc/php5/cli/php.ini)
php -i | grep 'php.ini'

Open file and search for curl section
vi /etc/php5/cli/php.ini
/curl

Add path to your curl binary
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an absolute path.
;curl.cainfo =
extension=/usr/lib/php5/20131226/curl.so

2. Get AdobeHDS.php script, which will assemble video fragments.

3. Get manifest url
Use Firefox Developer tools -> Web console. Filter on "manifest" or "f4m" and refresh the page with video.

Alternatively you can try "HDS Link Detector" extension.

Example: http://www.byutv.org/watch/livetv
Manifest: http://byuhd2-lh.akamaihd.net/z/byutvglobalhd2_live@103134/manifest.f4m?hdcore=2.10.3&g=TVZYNXO*****





4. Now you're ready to start the capture

Capture Start Script
php AdobeHDS.php --manifest "your_manifest_url" --delete

Capture Stop Script
#!/bin/sh 
pkill php
 
Links: F4F capturing converting

03 May 2016

Recording online radio - examples

1. Capturing ASF radio with mimms (e.g. FM Ushiku)
Filename includes current date, duration of the program is 30min, and it is converted to mp3. After that mp3 file is copied to SMB share.

Capture script

#!/bin/sh

now=$(date +"%m_%d_%Y")

url="mmsh://211.1.40.21:80/fmuu?MSWMExt=.asf"

output_filename=Bridge_For_Joy_${now}
output_filename2=Bridge_For_Joy_${now}.mp3

output_dir=/home/onosan/BridgeForJoy/

mimms -t 35 $url $output_dir$output_filename
avconv -i $output_dir$output_filename $output_dir$output_filename2
cd $output_dir
smbclient //<SMB SHARE> <PASSWORD> -U <USERNAME> << SMBCLIENTCOMMANDS
cd <FOLDER>
put $output_filename2
exit
SMBCLIENTCOMMANDS

2. Capturing MP3 streaming radio with wget

Start capture script


#!/bin/sh

now=$(date +"%m_%d_%Y")

url="http://219.117.222.167:8020/giglive"

output_filename=DJ_J_${now}.mp3

output_dir=/home/username/DJJ/

wget -O "$output_dir$output_filename" $url

Stop capture script

#!/bin/sh
pkill wget

3. Crontab entries example


0 8 * * 4 /home/username/DJJStart
0 9 * * 4 /home/username/DJJStop
13 13 * * 3 /home/username/mimms_capture