I try to remove link that have .opus in the filename using myjdapi but it fails to remove
JD API reference : here
Example of code that I use:
import myjdapi
import sys
try:
jd = myjdapi.Myjdapi()
jd.set_app_key("JDPeter") # name of your choice
# Connect using your username and password
jd.connect("[email protected]", "password")
# connection
if jd.is_connected():
print("Connected successfully.")
else:
print("Failed to connect.")
sys.exit()
# update device
jd.update_devices()
# print device
print("Dispositivi: ", jd.list_devices())
# Get the device you want to use
device = jd.get_device("JDownloader@abc") # Sostituisci con il nome del tuo dispositivo
# Test your device
if device:
print("Device obtained successfully.")
else:
print("Unable to obtain device.")
sys.exit()
# Now you can use the various API functions. For example, to get packages from the LinkGrabber:
packages = device.linkgrabber.query_packages([{
"bytesLoaded": True,
"bytesTotal": True,
"enabled": True,
"eta": True,
"finished": True,
"running": True,
"speed": True,
"status": True,
"childCount": True,
"hosts": True,
"saveTo": True,
"maxResults": -1,
"startAt": 0,
}])
# Iterate through packages
for package in packages:
# Print the package name
print("Pacchetto: ", package['name'])
# Check the connection
if not jd.is_connected():
print("Connessione persa. Tentativo di riconnessione...")
jd.connect("xxxx.com", "xxxx") # Sostituisci con il tuo email e password
if not jd.is_connected():
print("Impossibile ristabilire la connessione.")
sys.exit()
else:
print("Connessione ristabilita con successo.")
# Get package details
package_links = device.linkgrabber.query_links([{
"packageUUIDs": [package['uuid']]
}])
# Check if there are .m4a and .opus files in the package
m4a_exists = any(link['name'].endswith('.m4a') for link in package_links)
opus_links = [link for link in package_links if link['name'].endswith('.opus')]
# If a .m4a file exists, delete all .opus files
if m4a_exists and opus_links:
for opus_link in opus_links:
response = device.linkgrabber.remove_links([opus_link['uuid']], [package['uuid']])
print("Risposta da remove_links: ", response)
except Exception as e:
print("Errore: ", str(e))
The problem essentially my script lists both the packages and the names of the files within these packages, but it doesn't eliminate the names containing .opus as an extension
