Jdownloader2

From SME Server
Jump to navigationJump to search

Jdownloader2

JDownloader is a direct download manager that supports the most popular file sharing services. By copying the URL containing the files you want to download, the program will just add them automatically to its download list thanks to the link grabber feature. This software is 100% free and Open Source.


Warning.png Warning:
Only tested on SME Server 9.0


JDownloader is since many years my favorite download manager. He has indeed many positive points:

  • supports an impressive number of hosts (Uptobox, Rapidshare, Youtube, ... 1file.)
  • Java-based platform
  • support for multi-site premium subscriptions such alldebrid.com
  • supporting different types of captchas
  • controllable via a dedicated Android app or better a simple browser (my.jdownloader.org)
  • Free and open-source

Only an account is needed from my.jdownloader.org to use Jdownloader2

Howto

prepare and download

  • You need first to install java
yum install java-1.8.0-openjdk
  • you need to make a folder
 mkdir /usr/share/JD2
  • you need to download the java file
cd /usr/share/JD2
wget http://installer.jdownloader.org/JDownloader.jar

set JD

here you need an account with your password from http://my.jdownloader.org/

  • now you can launch the java software
java -Djava.awt.headless=true -jar /usr/share/JD2/JDownloader.jar

JD2 will ask to update, answer yes (y), then it need to restart

  • launch again the java software
 java -Djava.awt.headless=true -jar /usr/share/JD2/JDownloader.jar

here it will ask your jdownloader account.

Important.png Note:
at my first start, the former instance was not closed properly , I found these warnings when I launched JD2 the second time
-> existing jD instance found!
-> Send parameters to existing jD instance and exit: [--focus]

in fact you have to close JD

ps aux |grep JD

find the pid, for example here

kill -9 7336


start at boot time

now when you launch the command above your JD instance is able to run. we have to create an init script to run JD at the boot time

  • create the jdownloader system user
/sbin/e-smith/create-system-user jdownloader 810 "Jdownloader server" /var/lib/jdownloader /bin/bash
  • set good ownership
chown jdownloader:jdownloader /usr/share/JD2/ -R
  • create the db entry
db configuration set jdownloader service status enabled
  • create the initscript
vim /etc/rc.d/init.d/jdownloader

and paste this

#!/bin/sh
### BEGIN INIT INFO
# Provides: <NAME>
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: <DESCRIPTION>
### END INIT INFO

SCRIPT='java -Djava.awt.headless=true -jar /usr/share/JD2/JDownloader.jar'
RUNAS='jdownloader'
NAME='jdownloader'

PIDFILE=/var/run/$NAME.pid
LOGFILE=/dev/null

start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
  return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -s /bin/sh $RUNAS -c "$CMD" > "$PIDFILE"

sleep 5
PID=$(cat $PIDFILE)
  if pgrep -u $RUNAS -f "$SCRIPT" > /dev/null
  then
    echo "$NAME is now running, the PID is $PID"
  else
    echo "Error! Could not start $NAME!"
  fi

}

stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
  return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}

status() {
      printf "%-50s" "Checking $NAME..."
  if [ -f $PIDFILE ]; then
      PID=$(cat $PIDFILE)
          if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then
              printf "%s\n" "The process appears to be dead but pidfile still exists"
          else
              echo "Running, the PID is $PID"
          fi
  else
      printf "%s\n" "Service not running"
  fi
}


case "$1" in
start)
  start
  ;;
stop)
  stop
  ;;
status)
  status
  ;;
restart)
  stop
  start
  ;;
*)
  echo "Usage: $0 {start|stop|status|restart}"
esac

we need to get that script executable

chmod u+x /etc/rc.d/init.d/jdownloader

and set the time when we want it starts

chkconfig --add jdownloader
ln -s  /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S90jdownloader
signal-event remoteaccess-update

Retrieve the downloads

we need to make a samba fragment

vim /etc/e-smith/templates/etc/smb.conf/91jdownloader
{ my $status = $jdownloader{'status'} || "disabled";
   return "    # jdownloader is disabled in smb.conf"
          unless $status eq 'enabled';
       {
my @jdownloader_smb_users = split(",", ($jdownloader{'Smbusers'} || "") );

       $OUT .= "[jdownloader]\n";
       $OUT .= "comment = jdownloader download folder\n";
       $OUT .= "path = /var/lib/jdownloader\n";

       $OUT .= "valid users \= admin ";
       foreach my $jdownloader_smb_users (@jdownloader_smb_users)
       {
           $OUT .= " $jdownloader_smb_users";
       }
       $OUT .="\n";
       $OUT .= "force user = jdownloader\n";
       $OUT .= "force group = jdowloader\n";
       $OUT .= "read only = no\n";
       $OUT .= "browsable = yes\n";
       $OUT .= "writable = yes\n";
       $OUT .= "create mode = 0644\n";
       $OUT .= "directory mask = 0755\n";

       }
}

then

signal-event workgroup-update

and create the download folder and allow the jdownloader user

mkdir /var/lib/jdownloader
chown jdownloader:jdownloader /var/lib/jdownloader -R

adjust setting in Jdownloader

got to http://my.jdownloader.org, fill your credentials, go to your jdownloader instance (you can have several instance at my.jdownloader.org), go to the 'settings' (upper right) and then 'Advanced Settings' (on the left)

  • sort by General - Default Download Folder and set /var/lib/jdownloader
  • sort by Extraction - Delete Archive Downloadlinks After Extraction and valid the checkbox
  • sort by Extraction - Delete Archive Files After Extraction Action and select the file deletion of your choice
  • sort by General - Auto Start Download Option and choose 'always'
  • sort by General - Show Countdownon Auto Start Downloads and invalid the checkbox

of course you have plenty of different settings, take time to see them. add yours here if you think that they are valuable

Usage

  • web interface

Your web Interface is reachable at http://my.jdownloader.org, fill your credentials

  • control the service

you can control the service by

service jdownloader status
service jdownloader restart
service jdownloader start
service jdownloader stop
  • retrieve your downloads by samba

at first only the user admin is allowed to reach the samba share jdownloader, but you can add more users or groups (see below)

  • allow more users/groups to use the samba share

you need to set your group with a '@'

config setprop jdownloader Smbusers user1,user2,@group1,@group2
signal-event workgroup-update

Debug

launch manually in your terminal the command below and see what is wrong.

su -s /bin/sh jdownloader -c 'java -Djava.awt.headless=true -jar /usr/share/JD2/JDownloader.jar'