namboy94 / xdcc-dl

An XDCC File Downloader based on the irclib framework
GNU General Public License v3.0
62 stars 16 forks source link

Can't download a pack searched via a SearchEngine #18

Open deepred86 opened 3 years ago

deepred86 commented 3 years ago

Hi I'm unable to download a pack searched using XDCC_EU Search engine

from xdcc_dl.xdcc import download_packs
from xdcc_dl.pack_search import SearchEngines

results = SearchEngines.XDCC_EU.value.search("test")

download_packs(results)

I get:

Traceback (most recent call last): File "/home/user/PycharmProjects/pythonProject/main.py", line 7, in download_packs(results) File "/home/user/.local/lib/python3.8/site-packages/xdcc_dl/xdcc/init.py", line 51, in download_packs for pack in packs: TypeError: 'XDCCPack' object is not iterable

Even when using your example:

from xdcc_dl.xdcc import download_packs
from xdcc_dl.pack_search import SearchEngines
from xdcc_dl.entities import XDCCPack, IrcServer

# Generate packs
manual = XDCCPack(IrcServer("irc.rizon.net"), "bot", 1)
from_message = XDCCPack.from_xdcc_message("/msg bot xdcc send #2-10")
search_results = SearchEngines.HORRIBLESUBS.value.search("Test")
combined = [manual] + from_message + search_results

# Start download
download_packs(combined)

I get:

Traceback (most recent call last): File "/home/user/PycharmProjects/pythonProject/main.py", line 9, in combined = [manual] + from_message + search_results TypeError: can only concatenate list (not "XDCCPack") to list`

I also tried to add a random.choice() in order to select a random choice from the packs list returned by the SearchEngine function without success. Am I doing something wrong or is it a bug?

namboy94 commented 3 years ago

You don't seem to be doing anything wrong from what I can see, the code you posted seems to work on my end.

Maybe make sure you have the newest versions of both puffotter(0.17.2) and xdcc-dl(5.1.0) installed via pip. I can't really come up with any explanation what could be wrong otherwise right now.

deepred86 commented 3 years ago

They were updated so I reinstalled them just to double check, now I get:

/usr/bin/python3.8 /home/user/PycharmProjects/pythonProject/main.py
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/irc/client.py", line 186, in connect
    self.socket = self.connect_factory(self.server_address)
  File "/home/user/.local/lib/python3.8/site-packages/irc/connection.py", line 49, in connect
    sock.connect(server_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/xdcc_dl/xdcc/XDCCClient.py", line 179, in download
    self.connect(
  File "/home/user/.local/lib/python3.8/site-packages/irc/client.py", line 1166, in connect
    self.connection.connect(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/jaraco/functools.py", line 456, in wrapper
    return method(self, *args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/irc/client.py", line 188, in connect
    raise ServerConnectionError("Couldn't connect to socket: %s" % ex)
irc.client.ServerConnectionError: Couldn't connect to socket: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/PycharmProjects/pythonProject/main.py", line 9, in <module>
    download_packs(search_results)
  File "/home/user/.local/lib/python3.8/site-packages/xdcc_dl/xdcc/__init__.py", line 61, in download_packs
    client.download()
  File "/home/user/.local/lib/python3.8/site-packages/xdcc_dl/xdcc/XDCCClient.py", line 217, in download
    self.timeout_watcher_thread.join()
  File "/usr/lib/python3.8/threading.py", line 1006, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started

Process finished with exit code 1

Also, what would be the best way to select a random item from the results? I can't iterate it using a for loop or a random.choice()

namboy94 commented 3 years ago

I'm honestly not sure what the issue could be here. Maybe also update the irc package to the newest version. Does this also occur when using the command line tool xdcc-browse? If so, it could be that there's some issue on a network level, maybe firewall settings or IP bans?

Regarding picking a random item from the results: That should be possible using random.choice(), since the results should be a list of XDCCPack objects. I don't quite know why it wouldn't work.