Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Real-Debrid as Torrent Client #3027

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
37 changes: 27 additions & 10 deletions data/interfaces/default/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
<input type="radio" name="torrent_downloader" id="torrent_downloader_utorrent" value="2" ${config['torrent_downloader_utorrent']}> uTorrent (Beta)
<input type="radio" name="torrent_downloader" id="torrent_downloader_deluge" value="3" ${config['torrent_downloader_deluge']}> Deluge (Beta)
<input type="radio" name="torrent_downloader" id="torrent_downloader_qbittorrent" value="4" ${config['torrent_downloader_qbittorrent']}> QBitTorrent
<input type="radio" name="torrent_downloader" id="torrent_downloader_realdebrid" value="5" ${config['torrent_downloader_realdebrid']}> Real-Debrid
</fieldset>
<fieldset id="torrent_blackhole_options">
<div class="row">
Expand Down Expand Up @@ -442,6 +443,13 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
<input type="checkbox" name="deluge_paused" value="1" ${config['deluge_paused']}>
</div>
</fieldset>
<fieldset id="realdebrid_options">
<div class="row">
<label>API Key</label>
<input type="text" name="realdebrid_apikey" value="${config['realdebrid_apikey']}" size="30">
<small>Key can be acquired from <a href="https://real-debrid.com/apitoken" target="_blank">https://real-debrid.com/apitoken</a></small>
</div>
</fieldset>
<fieldset id="general_torrent_options">
<div class="row">
<label>Minimum seeders</label>
Expand Down Expand Up @@ -2423,29 +2431,34 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>

if ($("#torrent_downloader_blackhole").is(":checked"))
{
$("#transmission_options,#utorrent_options,#deluge_options,#qbittorrent_options").hide();
$("#transmission_options,#utorrent_options,#deluge_options,#qbittorrent_options,#realdebrid_options").hide();
$("#torrent_blackhole_options").show();
}
if ($("#torrent_downloader_transmission").is(":checked"))
{
$("#torrent_blackhole_options,#utorrent_options,#deluge_options,#qbittorrent_options").hide();
$("#torrent_blackhole_options,#utorrent_options,#deluge_options,#qbittorrent_options,#realdebrid_options").hide();
$("#transmission_options").show();
}
if ($("#torrent_downloader_utorrent").is(":checked"))
{
$("#torrent_blackhole_options,#transmission_options,#deluge_options,#qbittorrent_options").hide();
$("#torrent_blackhole_options,#transmission_options,#deluge_options,#qbittorrent_options,#realdebrid_options").hide();
$("#utorrent_options").show();
}
if ($("#torrent_downloader_qbittorrent").is(":checked"))
{
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#deluge_options").hide();
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#deluge_options,#realdebrid_options").hide();
$("#qbittorrent_options").show();
}
if ($("#torrent_downloader_deluge").is(":checked"))
{
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#qbittorrent_options").hide();
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#qbittorrent_options,#realdebrid_options").hide();
$("#deluge_options").show();
}
if ($("#torrent_downloader_realdebrid").is(":checked"))
{
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#qbittorrent_options,#deluge_options").hide();
$("#realdebrid_options").show();
}

$('input[type=radio]').change(function(){
if ($("#preferred_bitrate").is(":checked"))
Expand Down Expand Up @@ -2482,23 +2495,27 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
}
if ($("#torrent_downloader_blackhole").is(":checked"))
{
$("#transmission_options,#utorrent_options,#deluge_options,#qbittorrent_options").fadeOut("fast", function() { $("#torrent_blackhole_options").fadeIn() });
$("#transmission_options,#utorrent_options,#deluge_options,#qbittorrent_options,#realdebrid_options").fadeOut("fast", function() { $("#torrent_blackhole_options").fadeIn() });
}
if ($("#torrent_downloader_transmission").is(":checked"))
{
$("#torrent_blackhole_options,#utorrent_options,#deluge_options,#qbittorrent_options").fadeOut("fast", function() { $("#transmission_options").fadeIn() });
$("#torrent_blackhole_options,#utorrent_options,#deluge_options,#qbittorrent_options,#realdebrid_options").fadeOut("fast", function() { $("#transmission_options").fadeIn() });
}
if ($("#torrent_downloader_utorrent").is(":checked"))
{
$("#torrent_blackhole_options,#transmission_options,#deluge_options,#qbittorrent_options").fadeOut("fast", function() { $("#utorrent_options").fadeIn() });
$("#torrent_blackhole_options,#transmission_options,#deluge_options,#qbittorrent_options,#realdebrid_options").fadeOut("fast", function() { $("#utorrent_options").fadeIn() });
}
if ($("#torrent_downloader_qbittorrent").is(":checked"))
{
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#deluge_options").fadeOut("fast", function() { $("#qbittorrent_options").fadeIn() });
$("#torrent_blackhole_options,#transmission_options,#utorrent_options,#deluge_options,#realdebrid_options").fadeOut("fast", function() { $("#qbittorrent_options").fadeIn() });
}
if ($("#torrent_downloader_deluge").is(":checked"))
{
$("#torrent_blackhole_options,#utorrent_options,#transmission_options,#qbittorrent_options").fadeOut("fast", function() { $("#deluge_options").fadeIn() });
$("#torrent_blackhole_options,#utorrent_options,#transmission_options,#qbittorrent_options,#realdebrid_options").fadeOut("fast", function() { $("#deluge_options").fadeIn() });
}
if ($("#torrent_downloader_realdebrid").is(":checked"))
{
$("#torrent_blackhole_options,#utorrent_options,#transmission_options,#qbittorrent_options,#deluge_options").fadeOut("fast", function() { $("#realdebrid_options").fadeIn() });
}
});

Expand Down
1 change: 1 addition & 0 deletions headphones/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def __repr__(self):
'UTORRENT_PASSWORD': (str, 'uTorrent', ''),
'UTORRENT_USERNAME': (str, 'uTorrent', ''),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'REALDEBRID_APIKEY': (str, 'Real-Debrid', ''),
'WAIT_UNTIL_RELEASE_DATE': (int, 'General', 0),
'WAFFLES': (int, 'Waffles', 0),
'WAFFLES_PASSKEY': (str, 'Waffles', ''),
Expand Down
25 changes: 24 additions & 1 deletion headphones/postprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from beets import logging as beetslogging
from beets.mediafile import MediaFile, FileTypeError, UnreadableFileError
from beetsplug import lyrics as beetslyrics
from headphones import notifiers, utorrent, transmission, deluge, qbittorrent
from headphones import notifiers, utorrent, transmission, deluge, qbittorrent, realdebrid
from headphones import db, albumart, librarysync
from headphones import logger, helpers, mb, music_encoder
from headphones import metadata
Expand Down Expand Up @@ -61,6 +61,8 @@ def checkFolder():
torrent_folder_name, single = transmission.getFolder(album['TorrentHash'])
elif headphones.CONFIG.TORRENT_DOWNLOADER == 4:
torrent_folder_name, single = qbittorrent.getFolder(album['TorrentHash'])
elif headphones.CONFIG.TORRENT_DOWNLOADER == 5:
torrent_folder_name = realdebrid.getFolder(album['TorrentHash'])
if torrent_folder_name:
folder_name = torrent_folder_name

Expand Down Expand Up @@ -207,6 +209,21 @@ def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=Fal
downloaded_track_list = []
downloaded_cuecount = 0

if Kind == 'torrent' and headphones.CONFIG.TORRENT_DOWNLOADER == 5:
# Real-Debrid is the torrent downloader, so we check if the download is complete
# here, because it won't actually download the files locally until we tell it to
snatched = myDB.action('SELECT * from snatched WHERE AlbumID=? and FolderName=?', [albumid, os.path.basename(albumpath)]).fetchone()
try:
done = realdebrid.checkStatus(snatched['TorrentHash'])
except LookupError:
myDB.action('DELETE FROM snatched WHERE TorrentHash=?', [snatched['TorrentHash']])

if not done:
logger.info(
"Looks like " + os.path.basename(albumpath).decode(headphones.SYS_ENCODING,
'replace') + " isn't complete yet. Will try again on the next run")
return

for r, d, f in os.walk(albumpath):
for files in f:
if any(files.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS):
Expand All @@ -228,6 +245,10 @@ def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=Fal
if (headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent") or headphones.CONFIG.KEEP_ORIGINAL_FOLDER:
keep_original_folder = True

# If we're using real-debrid, we don't want to keep the original
if headphones.CONFIG.TORRENT_DOWNLOADER == 5 and Kind == "torrent":
keep_original_folder = False

# Split cue before metadata check
if headphones.CONFIG.CUE_SPLIT and downloaded_cuecount and downloaded_cuecount >= len(
downloaded_track_list):
Expand Down Expand Up @@ -495,6 +516,8 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
torrent_removed = deluge.removeTorrent(hash, True)
elif headphones.CONFIG.TORRENT_DOWNLOADER == 2:
torrent_removed = utorrent.removeTorrent(hash, True)
elif headphones.CONFIG.TORRENT_DOWNLOADER == 5:
torrent_removed = realdebrid.removeTorrent(hash)
else:
torrent_removed = qbittorrent.removeTorrent(hash, True)

Expand Down
Loading