expected string in bencoded string

Пробовал модуль bencode.py. Проблема в том, что bencode.bdecode на входе хочет строку, а файл по определению — байты.

П.С. А где тег для 3го питона?

Добавлено: Вся проблема в ссаном третьем питоне, во втором все работает на ура.

  • Вопрос задан более двух лет назад
  • 331 просмотр

берешь либу
импортируешь
считываешь

либу за тебя уже написали

нужно брать другую
или эту доводить до ума, посмотреть ее методы, например, и поправить
но проще другую ), там файл сразу считывается в обьект и с ним можно работать, не гадать как в твоем примере

Comments

Copy link Quote reply

moffeemoffee commented Nov 22, 2017

Please provide the following information

qBittorrent version and Operating System

qBittorrent v4.0.1, Windows 10

If on linux, libtorrent and Qt version

What is the problem

Upon double clicking a torrent in the RSS feed, I am hit with this error:

Failed to load torrent: C:Users. AppDataLocalTemp.qBittorrentOCQ772
Error: expected value (list, dict, int or string) in bencoded string

What is the expected behavior

The torrent clicked will download

Steps to reproduce

Open RSS, double click any torrent

Extra info(if any)

This comment has been minimized.

Copy link Quote reply

dstorrez commented Nov 27, 2017 •

Linux Ubuntu 16.04 LTS
qBittorrent v4.0.1
RSS feed: https://yts.am/rss/0/all/all/0

I have the same problem with YTS.ag RSS feed. It stared a few day ago. If I double click rss feeds from last week its fine but any of the new ones I get «Failed to load the torrent: /tmp/.qBittorrent/p14121.
Error: expected value (list, dict, int or string) in bencoded string»

This comment has been minimized.

Copy link Quote reply

glassez commented Nov 27, 2017

Fixed in master. Fix will be release with v.4.0.2.

This comment has been minimized.

Copy link Quote reply

dstorrez commented Dec 4, 2017

I just installed v.4.0.2 and the problem is still there.
_Failed to load the torrent: /tmp/.qBittorrent/s14765.
Error: expected value (list, dict, int or string) in bencoded string

I’ll post an update once the RSS updates with new feeds just in case its just an old file handled wrong.

This comment has been minimized.

Copy link Quote reply

glassez commented Dec 5, 2017

@dstorrez, if you mean the feed above it works properly now (tested one more time just now). Apparently you tried to load torrent from already corrupted article (loaded by previous qBittorrent version).

This comment has been minimized.

Copy link Quote reply

dstorrez commented Dec 6, 2017

@glassez You are 100% correct. its working perfectly now. Thank you for the follow up.
I checked today’s feed and everything came through the way it was supposed to.

This comment has been minimized.

Copy link Quote reply

whoever81 commented Dec 29, 2017 •

v.4.0.3 (Windows 10) The problem persists.

This comment has been minimized.

Copy link Quote reply

glassez commented Dec 29, 2017

v.4.0.3 (Windows 10) The problem persists.

What is affected feed URL?

This comment has been minimized.

Copy link Quote reply

whoever81 commented Dec 30, 2017

I am not very familiar with the term «feed URL». Double click to download torrents in the search results. Problem appears sometimes not always.

This comment has been minimized.

Copy link Quote reply

glassez commented Dec 30, 2017

What «search results» you’re talking about?
FYI, this issue is about downloading torrents from RSS feeds (assuming someone who use RSS should understand «feed URL» term).

This comment has been minimized.

Copy link Quote reply

whoever81 commented Dec 30, 2017 •

Sorry for my «noobity». I am referring to the search function/tab in qbittorrent. You search for a term. A list of torrents comes up (search results). You double click one to download.

This comment has been minimized.

Copy link Quote reply

glassez commented Dec 30, 2017

You choose wrong topic for your issue (besides, closed). You should create the new one (unless you find the existing one with the similar problem). Otherwise you risk to remain without a solution to your problem.
What you have describe here is merely the symptoms and not the problem itself. It can be caused by various problems. In your case it could be either a wrong/outdated search plugin, or incorrect return value of search site, or something else. In any case, you should ask the devs familiar with search engine/plugins.

I am a bit confused with bencoding.

According to the specification when I bencode string I need to use the following format:

length:string

String spam becomes 4:spam

My question: 4 is qty of symbols of bencoded string, or qty of utf-8 bytes?

For instance, if I am going to bencode a string gâteau

What number should be specified as a length of this string?

I think I have to specify 7, and the final form should be 7:gâteau

It is because symbol â took 2 bytes accoring to utf-8 encoding, and all the rest symbols in this string took 1 byte according to utf-8 encoding.

Also I heard that it is not recommended to store bencoded data in java String instance.

In other words, when I bencode a data block, I should store it as a byte array and should not convert it to java String value to avoid encoding issues.

Оцените статью
SoftLast
Добавить комментарий