Sunday, June 12, 2016

Making Transmission and RSS best buddies

Ok here is the thing. I will keep coming back till I am alive.

Today, just to waste sometime, decided to find a way by which I can add rss support to transmission.

Thanks to this post, I found a way with the help of this script.

BUT there are problems with the script -

1. It will parse the rss and add the torrents to transmission's queue. But is if happen to delete the torrent, it will again add it.
2. There is no log file which it can refer to while deciding about downloading it.

Then I summon the my coding super powers to modify the script. Now my script while parsing the  RSS also refers to the log file and checks the title of the torrent. If it is there, script will not add the torrent. Rather it will display a message like below

Torrent Already Downloaded / or in queue: Torrent Name
 Here is my script. https://github.com/nigamankit7/transmission-rss

Now steps to set it up -

  1. Open SSH and connect to your cloud
  2. Install Transmission (I used this  tutorial)
  3. Go to your home dir or anywhere you like
    cd ~/
  4. Download chinese PHP script with wget:
    wget https://raw.githubusercontent.com/nigamankit7/Transmission-RSS/master/rss.php
  5. Edit the config section at the end of the file with any text editor
       nano rss.php
 Here is the list of RSS links (it can be more than one. Just delete all of them here and put yours. Remember to omit the comma after the last link.
$rss = array(
    'http://chdbits.org/torrentrss.php...',
    'http://totheglory.im/putrssmc.php...',
    'https://hdcmct.org/torrentrss.php...',
    'https://open.cd/torrentrss.php?.....',
    'https://mv.open.cd/torrentrss.php?..',
    'http://hdwing.com/rss.php?..........',
    'http://hdtime.org/torrentrss.php?...'
);
 Internal IP to your cloud (it's better to use static local IP, I'm not sure if the name would work like on your computer)
$server = 'http://127.0.0.1';
 Access port to Transmission (if you haven't change it, skip it)
$port = 9091;
 RPC path for Transmission (same here, skip it if you haven't changed it)
$rpcPath = '/transmission/rpc';
 Credentials for your Transmission (empty by default)
$user = '';
$password = '';
  1. Save and exit
  2. Test your script with
    php rss.php
 If all goes well, it should return a list of found links and added to Transmission, for example:
success add torrent: Two and a Half Men 12x09 Bouncy, Bouncy, Bouncy, Lyndsey 720p
success add torrent: The Big Bang Theory 8x12 The Space Probe Disintegration 720p
success add torrent: Forever 1x12 720p
success add torrent: The Mentalist 7x06 Green Light 720p
  1. Check your Transmission web UI if they are downloading.
  2. Now we can add the task to cron. Edit the cron with
    crontab -e
  3. You should see at least one line with Transmission daemon. We need to add another line, like
    */10 * * * * php ~/rss.php >> /var/log/rss.log 2>&1
 or the one without logs

*/10 * * * * php ~/rss.php

 This should run our script every 10 mins.

MAKE SURE CRON IS ENABLED ON RASPBERRY

EDIT - "/home/pi/.kodi/userdata/addon_data/script.raspbmc.settings/settings.xml"

SET :  sys.service.cron TO "true"

Friday, April 24, 2015

TRakt plugin for VLC on Windows

One more reason to bid adieu to XBMC.

What a wonderful plugin from Raphaël Beamonte called TraktForVLC. Only setting it up is a tad bit of work.

Steps to get it working

1. Download the repo and extract it to a folder. I kept it in Dropbox for i don't want to do all the config again.

2. Follow the instruction given with the repo- https://github.com/nigamankit7/TraktForVLC

3. Make sure you update the name of two files as below

config.ini.default –> config.ini (in default folder)

config.bat.default –> config.bat (in windows_batch folder)

4. Also update config.bat file with all the paths. Use double quotes in batch files wherever path has spaces.

5. keep the shortcut of start.bat in startup folder.

6. If you want to check if the code is working check the log folder.

-Cheers !!

TRakt plugin for VLC on Windows

What a wonderful plugin from Raphaël Beamonte called TraktForVLC. Only setting it up is a tad bit of work.

Steps to get it working

1. Download the repo and extract it to a folder. I kept it in Dropbox for i don't want to do all the config again.

2. Follow the instruction given with the repo- https://github.com/nigamankit7/TraktForVLC

3. Make sure you update the name of two files as below

config.ini.default –> config.ini (in default folder)

config.bat.default –> config.bat (in windows_batch folder)

4. Also update config.bat file with all the paths. Use double quotes in batch files wherever path has spaces.

5. keep the shortcut of start.bat in startup folder.

6. If you want to check if the code is working check the log folder.

Friday, March 6, 2015

Automatically backup your files as soon as UBD Flash or HDD is connected

One of a great tool available to sync file is SyncTool from Microsoft. You my download a copy free of cost and installation & use is self explanatory.

Now, I don’t want to open the sync tool every time manually when I connect the HDD. My objective is to take the backup as soon as the USB HDD or flash drive is connect just like time machine backup in MAC.

I wrote a powershell script which I scheduled with task scheduler while booting. This script keeps on running like a deamon and keep on checking for the USB connection. Once the correct USB is connect with predefined name, it starts the sync tool and start syncing for each partnership sequentially.

One more benefit is that this script keeps on running in background and when the backup is started and completed, a balloon notification is shown to the user along with the path to log files. You may need to change the line number as per your case.

 

clear
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
$TARGETDIR = $dir + "\log"


if(!(Test-Path -Path $TARGETDIR ))
{
    New-Item -ItemType directory -Path $dir -Name "log"
}
$logFile = $TARGETDIR + "\sync.log"


function baloon-notify($logpath, $title_tip, $title)
    {   write-host "logpath : " $logpath
        write-host "titl tip : "  $title_tip  
        write-host "Title : " $title
        [void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)#Remove any registered events related to notifications
        Remove-Event BalloonClicked_event -ea SilentlyContinue
        Unregister-Event -SourceIdentifier BalloonClicked_event -ea silentlycontinue
        Remove-Event BalloonClosed_event -ea SilentlyContinue
        Unregister-Event -SourceIdentifier BalloonClosed_event -ea silentlycontinue
        $notification = New-Object System.Windows.Forms.NotifyIcon
        $notification.Icon = [System.Drawing.SystemIcons]::Information
        $notification.BalloonTipTitle = $title_tip
        $notification.BalloonTipIcon = “info”
        $notification.BalloonTipText = $title + $logpath
        $notification.Visible = $True
        register-objectevent $notification BalloonTipClicked BalloonClicked_event `
        -Action {Invoke-Item $logpath} | Out-Null
        $notification.ShowBalloonTip(600)
    }


 



function Run-SyncToy ($backupPlan)
{
    $Exe = "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe"
    & $Exe -R #$backupPlan
}


Register-WmiEvent -Class win32_VolumeChangeEvent -SourceIdentifier volumeChange -ea silentlycontinue 
write-host (get-date -format s) " Beginning script..."
do{
    $newEvent = Wait-Event -SourceIdentifier volumeChange
    $eventType = $newEvent.SourceEventArgs.NewEvent.EventType
    $eventTypeName = switch($eventType)
    {
        1 {"Configuration changed"}
        2 {"Device arrival"}
        3 {"Device removal"}
        4 {"docking"}
    }
    write-host (get-date -format s) " Event detected = " $eventTypeName
    if ($eventType -eq 2)
    {
        $driveLetter = $newEvent.SourceEventArgs.NewEvent.DriveName
        $driveLabel = ([wmi]"Win32_LogicalDisk='$driveLetter'").VolumeName
        write-host (get-date -format s) " Drive name = " $driveLetter
        write-host (get-date -format s) " Drive label = " $driveLabel
        # Execute process if drive matches specified condition(s)
        if ($driveLetter -eq 'H:' -and $driveLabel -eq 'Ankit')
            {
            write-host (get-date -format s) " Starting task in 3 seconds..."
            start-sleep -seconds 3
            write-host (get-date -format s)" Sync Process started"
            $tip = "Auto Sync Started.Do not remove USB."
            $text = "SyncToy started syncing. Do not remove USB till next notification."
            baloon-notify $TARGETDIR $tip $text
            Run-SyncToy ("Media Sync") | out-file $logFile -Append -Force
            write-host (get-date -format s) " Sync Process Ended"
            $tip = "Auto Sync Completed"
            $text = "Path to log file ->"
            baloon-notify $logFile $tip $text
            }
    }
    Remove-Event -SourceIdentifier volumeChange
} while (1-eq1) #Loop until next event


Unregister-Event -SourceIdentifier volumeChange

 

Thursday, March 5, 2015

Updating Sickrage - PAIN

the other day I installed sickrage on my raspberry pi and today morning I found that there are 200+ commits are are not updated on my installation.

We I tried all sorts to update my installation but nothing worked out. Ultimately I decided to stay with the current version. BUT to my surprise, my sickrage installation stopped downloading any new episode.

I need to do something now. Below are the steps followed to fix the issue. (taking a backup of sickrage via its web UI is never a bad idea before starting.)



mv /home/pi/sickrage/ /home/pi/sickrage-backup

sudo git clone https://github.com/SiCKRAGETV/SickRage.git /home/pi/sickrage

sudo chown -R 777 /home/pi/sickrage

sudo chmod -R 777 /home/pi/sickrage

cp /home/pi/sickrage-backup/config.ini /home/pi/sickrage/

cp /home/pi/sickrage-backup/sickbeard.db /home/pi/sickrage/

mkdir /home/pi/sickrage/cache

cp -a /home/pi/sickrage-backup/cache/. /home/pi/sickrage/cache/

sudo service sickrage start



Followed by a system reboot the issue is resolved with all my data intact. 

Sunday, March 1, 2015

Installing sickrage on RASPBMC

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install python-cheetah git-core -y
wget http://sourceforge.net/projects/bananapi/files/unrar_5.0.10-1_armhf.deb
sudo dpkg -i unrar_5.0.10-1_armhf.deb
sudo git clone https://github.com/SiCKRAGETV/SickRage.git /home/pi//sickrage
sudo chown -R 777 /home/pi/sickrage
sudo chmod -R 777 /home/pi/sickrage
python /home/pi/sickrage/SickBeard.py -d
sudo apt-get install upstart
sudo nano /etc/init/sickrage.conf
#author "HTPCGuides.com"
#description "Upstart Script to run SickRage as a service on Ubuntu/Debian based systems"

#Set username for the process. Should probably be what you use for logging in

start on runlevel [2345]
stop on runlevel [016]

respawn

exec su - pi -c "python /home/pi/sickrage/SickBeard.py"
sudo service sickrage start

Friday, February 27, 2015

Setup Bit-torrent Sync on RASPBMC

 Fist we need add some repositories. Since Raspbmc do not allow the addition of new repository directly and hence do the following.


sudo apt-get install software-properties-common python-software-properties
sudo apt-get update

Now we can try below command

sudo echo deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo apt-get update
sudo apt-get install btsync

Note that if you get permission errors on the sources.list.d file, try editing the file manually with Nano:

sudo nano /etc/apt/sources.list.d/btsync.list

and paste in these lines.

deb http://debian.yeasoft.net/btsync wheezy main contrib non-free
deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free

save and close the file followed by update. 

sudo apt-get update
Sudo apt-get install btsync

Once btsync installation is started - choose the user - "pi" and group - "default"

After the installation of btsync grant read write permission on the external drive.

sudo chmod -R 777 /media/Ankit/
sudo chown pi /media/Ankit/

Open the btsync webpage with URL http://my_Pi_IP:8888/gui