Skip to content

Commit

Permalink
Fixed RD multiple torrent adding, fixed russian and indian language, …
Browse files Browse the repository at this point in the history
…added dutch
  • Loading branch information
aymene69 committed Feb 23, 2024
1 parent 6474638 commit 3e9320d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
40 changes: 30 additions & 10 deletions debrid/realdebrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,45 @@
import time


def is_already_added(magnet, config):
hash = magnet.split("urn:btih:")[1].split("&")[0].lower()
print("Getting Real-Debrid torrents")
url = "https://api.real-debrid.com/rest/1.0/torrents"
headers = {
"Authorization": f"Bearer {config['debridKey']}"
}
response = requests.get(url, headers=headers)
data = response.json()
for torrent in data:
if torrent['hash'] == hash:
return torrent['id']
return None



def get_stream_link_rd(query, config):
print("Started getting Real-Debrid link")
magnet = json.loads(query)['magnet']
type = json.loads(query)['type']
print("Getting config")
print("Got config")
print("Adding magnet to Real-Debrid")
url = "https://api.real-debrid.com/rest/1.0/torrents/addMagnet"
torrent_id = is_already_added(magnet, config)
print(torrent_id)
headers = {
"Authorization": f"Bearer {config['debridKey']}"
}
data = {
"magnet": magnet
}
response = requests.post(url, headers=headers, data=data)
data = response.json()
torrent_id = data['id']
print("Added magnet to Real-Debrid. ID: " + torrent_id)
if torrent_id:
print("Torrent already added to Real-Debrid. ID: " + torrent_id)
else:
url = "https://api.real-debrid.com/rest/1.0/torrents/addMagnet"
data = {
"magnet": magnet
}
response = requests.post(url, headers=headers, data=data)
data = response.json()
torrent_id = data['id']
print("Added magnet to Real-Debrid. ID: " + torrent_id)
print("Getting torrent info")
url = "https://api.real-debrid.com/rest/1.0/torrents/info/" + torrent_id
response = requests.get(url, headers=headers)
Expand Down Expand Up @@ -92,5 +113,4 @@ def get_stream_link_rd(query, config):
response = requests.post(url, headers=headers, data=data)
data = response.json()
print("Unrestricted link")
return data['download']

return data['download']
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ <h2 class="text-base font-semibold leading-7 text-gray-900">Filtering</h2>
<option value="de">🇩🇪</option>
<option value="it">🇮🇹</option>
<option value="pt">🇵🇹</option>
<option value="ru">🇷🇺</option>
<option value="in">🇮🇳</option>
<option value="nl">🇳🇱</option>
</select>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion utils/parse_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_emoji(language):
"pt": "🇵🇹",
"ru": "🇷🇺",
"in": "🇮🇳",
"nl": "🇳🇱",
"multi": "🌍"
}
return emoji_dict.get(language, "🇬🇧")
Expand All @@ -68,7 +69,8 @@ def detect_language(torrent_name):
"it": r'\b(ITALIAN|IT|ITA)\b',
"pt": r'\b(PORTUGUESE|PT|POR)\b',
"ru": r'\b(RUSSIAN|RU|RUS)\b',
"in": r'\b(INDIAN|IN|HINDI|TELUGU|TAMIL|KANNADA|MALAYALAM|PUNJABI|MARATHI|BENGALI|GUJARATI|URDU|ODIA|ASSAMESE|KONKANI|MANIPURI|NEPALI|SANSKRIT|SINHALA|SINDHI|TIBETAN|BHOJPURI|DHIVEHI|KASHMIRI|KURUKH|MAITHILI|NEWARI|RAJASTHANI|SANTALI|SINDHI|TULU)\b'
"in": r'\b(INDIAN|IN|HINDI|TELUGU|TAMIL|KANNADA|MALAYALAM|PUNJABI|MARATHI|BENGALI|GUJARATI|URDU|ODIA|ASSAMESE|KONKANI|MANIPURI|NEPALI|SANSKRIT|SINHALA|SINDHI|TIBETAN|BHOJPURI|DHIVEHI|KASHMIRI|KURUKH|MAITHILI|NEWARI|RAJASTHANI|SANTALI|SINDHI|TULU)\b',
"nl": r'\b(DUTCH|NL|NLD)\b',
}

for language, pattern in language_patterns.items():
Expand Down
1 change: 1 addition & 0 deletions utils/process_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def get_emoji(language):
"pt": "🇵🇹",
"ru": "🇷🇺",
"in": "🇮🇳",
"nl": "🇳🇱",
"multi": "🌍"
}
return emoji_dict.get(language, "🇬🇧")
Expand Down

0 comments on commit 3e9320d

Please sign in to comment.