question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

convert_magnet failing because of incompatible libtorrent python-bindings

See original GitHub issue

Expected behaviour:

convert_magnet plugin converts magnet uri into torrent file

Actual behaviour:

convert_magnet plugin does not convert magnet uri into torrent file (see log lines) due to incompatibility in libtorrent python bindings

Steps to reproduce:

  • Step 1: run flexget execute

Config:

schedules:
  - tasks: '*'
    interval:
      minutes: 1

tasks:
  test task:
    rss: http://rarbg.to/rssdd.php
    accept_all: yes
    download: /downloads/
    convert_magnet: yes

Log:

(click to expand)
2019-08-02 22:00 INFO     convert_magnet test task       Converting entry ------------------ magnet URI to a torrent file
2019-08-02 22:00 ERROR    convert_magnet test task       Unable to convert Magnet URI for entry ------------------:
    Python argument types in libtorrent.add_magnet_uri(session, str, add_torrent_params) did not match C++ signature:
    add_magnet_uri(libtorrent::session {lvalue}, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::python::dict)

Additional information:

  • FlexGet version: 2.21.15
  • Python version: 3.7.4
  • Installation method: pip
  • Using daemon (yes/no): yes
  • OS and version: alpine 3.10
  • Link to crash log: if you really want it I can provide one, but I think the error message in the log speaks for itself

So, in my case this function is failing. According to the libtorrent docs, the method called add_magnet_uri is actually deprecated (I don’t know since when). Though I find it odd to update a deprecated function, the documentation also offers an alternative way of doing things:

A simpler way to add a magnet link to a session is to pass in the link through add_torrent_params::url argument to session::add_torrent().

I think I got it working making these changes:

-        handle = libtorrent.add_magnet_uri(session, magnet_uri, params)
+        params.url = magnet_uri
+        handle = session.add_torrent(params)

However, it seems a large number of libtorrent versions are supported and I have no way of knowing for how many other people running older versions this change will actually break. To be on the safe side, we can add a version check to get the handle value in this way.

Software installed:

# apk list | grep "libtorrent\|boost" | grep installed
boost-python3-1.69.0-r5 x86_64 {boost} (custom) [installed]
boost-system-1.69.0-r5 x86_64 {boost} (custom) [installed]
libtorrent-rasterbar-1.2.1-r0 x86_64 {libtorrent-rasterbar} (BSD-3-Clause) [installed]
py3-libtorrent-rasterbar-1.2.1-r0 x86_64 {libtorrent-rasterbar} (BSD-3-Clause) [installed]

Can somebody verify my assumptions and make a PR ?

Edit The reason I wrote it as params.url = instead of params['url'] = (like the info_hash) is because this raised an error:

TypeError: 'add_torrent_params' object does not support item assignment

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
RangerRickcommented, Apr 28, 2020

I can confirm that making the change @cpoppema suggests fixes magnet conversion for me

0reactions
eSoarescommented, Jan 5, 2021

Close the issue, the PR #2797 fixed it (just updated and tested it!).

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found