simonc56 / rtorrent-disk-checker

Python 2 & 3 Worry Free rTorrenting
8 stars 1 forks source link

How to run the script on 0.9.6 rtorrent #1

Open amlopin opened 4 years ago

amlopin commented 4 years ago

Hi, My current seedbox provider does not have support for the newest rtorrent versions. I can only use 0.9.6. I tried to use your script with 0.9.6 but it is not working. On 0.9.7 and 0.9.8 working perfect. I would like to know how I could run your script with 0.9.6 rtorrent.

Many thanks

simonc56 commented 4 years ago

I think it's because of d.is_meta variable which is not available before version 0.9.7 (same as https://github.com/JADRIVAS/RTORRENT-IMDB-DISK-CHECKER/issues/8)

As a quick answer, I'd ask you to change in your .rtorrent.rc file, this text : branch=((and,((not,((d.is_meta)))),((d.state)))),((stpcheck)) to be replaced by branch=((d.state)),((stpcheck))

...and restart rtorrent .

amlopin commented 4 years ago

Ok I will do, so the bottom line would be: method.set_key = event.download.inserted_new, checker, "if=((d.state)),((stpcheck))" Many thanks

simonc56 commented 4 years ago

What happened, give details. Did it start, stayed stopped,...

amlopin commented 4 years ago

You're right, sorry. Torrents are not removing. Everything seems to be ok until I run out space... so they aren't removing.I use to feed it rss and autodl, 6 private trackers,very active. Thanks

simonc56 commented 4 years ago

Check modification dates of torrent.py and torrents.py files. If they are not the same as your last torrent added date, it means the script does not run upon torrent add. Also, give logs please (like this).

amlopin commented 4 years ago

Thanks for your support. Sorry to ask but where can I find torrent.py and torents.py?

simonc56 commented 4 years ago

Inside script folder. I guess they are not there so I assume the script is not run at torrent start, which means the 2 lines we add in .rtorrent.rc are not properly accepted by rtorrent. I must say that it will not be easy to help you remotely. I don't have a rtorrent 0.9.6 to try myself.

Another suggestion, replace the 2 lines by this single line : method.set_key = event.download.inserted_new, checker, d.stop=, "execute.throw.bg=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py,$d.name=,$d.custom1=,$d.hash=,$d.directory=,$d.size_bytes="

Then restart rtorrent, add a torrent and check if torrent.py and torrents.py are added.

amlopin commented 4 years ago

Ah ok I know why I didnt find them they were not there. I replaced that single line, restarted rtorrent, added some torrents and now they are stopping in rtorrent. torrent.py and torrents.py are not there Many many thanks for your help What else can I do?

simonc56 commented 4 years ago

Give logs after you add a torrent please.

amlopin commented 4 years ago

my .rtorrent.rc is: https://pastebin.com/t1VwyGi7

Many thanks for looking into

simonc56 commented 4 years ago

Ok, the script is correctly launched. Good point. Your .rtorrent.rc looks very small now. You didn't remove all line, did you?

Now, if your torrents still remain at stopped state, could you run the script manually so we can see the error output if there are. To do so, choose a stopped torrent of your seedbox and run this command in your terminal : python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Name.of.Torrent XXX /home/USER/torrents/rtorrent/Name.of.Torrent 1000000000

where XXX= torrent hash (must be exact) and 1000000000 = torrent size in bytes (no need to be exact).

as an example: python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Killing.Eve.S03E08.1080p.HDTV.H264-MTB 489BE13C0103A5C96C83DEE48A9B331D421A5A33 /home/USER/torrents/rtorrent/Killing.Eve.S03E08.1080p.HDTV.H264-MTB 884785784

Then, check if torrent starts. Check if torrent.py and torrents.py are created. And of course, copy the output of the command here. Good luck!

amlopin commented 4 years ago

Thanks for your support. my .rtorrent.rc remains the same but I just changed that lines you said on the top of the rtorrent.rc I hope they are ok. I removed that torrent, but I added another one. I managed to run that command, I think I did ok. This is the output:

python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Doe.2018.720p.WEB.h264-WATCHER 30F223EE8AC88C5585FFD3D4808739E07B762C44 /home/USER/torrents/rtorrent/Doe.2018.720p.WEB.h264-WATCHER 2018465627 Traceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 13, in torrent_size = int(sys.argv[5]) / 1073741824.0 IndexError: list index out of range

Torrent size is around 1.8Gb Torrent.py and torrents.py are not created.

EDIT: I´ve just checked "top" on SSH and I got around 10 python process and increasing every few seconds.. Many thanks

simonc56 commented 4 years ago

I gave you wrong command line (forgot label), do it again but add some text between name and hash : python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Doe.2018.720p.WEB.h264-WATCHER test 30F223EE8AC88C5585FFD3D4808739E07B762C44 /home/USER/torrents/rtorrent/Doe.2018.720p.WEB.h264-WATCHER 2018465627

I also forgot to tell : you must remove *.txt files of the script folder before each test of torrent add.

amlopin commented 4 years ago

Thanks for your help. It is working. I add a torrent and it is stopped but when I run that command it is activated. I am going to do it again and paste here a log in a minute. I hope you can find the issue Forgot to say that I removed *.txt files and now Torrent.py and torrents.py are created.

simonc56 commented 4 years ago

Can you add thise 2 lines at beginning (line 3) of checker.py :

with open('/home/USER/RTORRENT-IMDB-DISK-CHECKER/log.txt', 'a+') as txt:
        txt.write("test")

Do respect indentation (8 spaces on second line) it's important.

Then remove *txt files, add a torrent and go check if a log.txt file is created. This will tell us if python script is launched or not.

amlopin commented 4 years ago

Thanks again. Yes, log.txt is created, inside is word "test"

simonc56 commented 4 years ago

If you start a torrent with and another without label, does both stay at stopped state ?

amlopin commented 4 years ago

What is "label" when you say "with and another without label"? Is "test" the label in this command? python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Doe.2018.720p.WEB.h264-WATCHER test 30F223EE8AC88C5585FFD3D4808739E07B762C44 /home/USER/torrents/rtorrent/Doe.2018.720p.WEB.h264-WATCHER 2018465627

simonc56 commented 4 years ago

Yes. But I'd like you to try during normal torrent adding, on your seedbox interface. I try to find if no label is the problem. Don't forget to remove text files between your tests.

image

amlopin commented 4 years ago

Thanks I understand now. Without label torrent turn up at stopped state With label torrent turn up at queue state and change to stop after couple of seconds. If I dont run the command torrents are stopped and *.txt, torrent.py and torrents.py are not created.

simonc56 commented 4 years ago

Ok, strange that script can run manually but not from rtorrent. Does the rtorrent user have read access in /home/USER/RTORRENT-IMDB-DISK-CHECKER/ folder ?

amlopin commented 4 years ago

It is a seedbox, not my server. Havent got sudo. I´ve just checked in filezilla and aparently I got chmod 755 in that folder.

simonc56 commented 4 years ago

Is /home/USER/RTORRENT-IMDB-DISK-CHECKER/log.txt updated at every torrent add from seedbox interface ? I don't know how to help you more, this project have no logging so it's hard to debug.

amlopin commented 4 years ago

log.txt is not updated cause it is not created when I add torrents from seedbox. It only appear when I run that command. The same happen with *.txt, torrent.py and torrents.py are not created. Nothing is created when add torrents manually, rss, autodl. All start to work when I run the command I know it is hard for you, understand. Many many thanks

simonc56 commented 4 years ago

It seems we can capture output of command with execute.capture_nothrow.

You can edit your .rtorrent.rc as follow : method.set_key = event.download.inserted_new, checker, d.stop=, "execute.capture_nothrow=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py,$d.name=,$d.custom1=,$d.hash=,$d.directory=,$d.size_bytes="

also change delay in checker.py at end of the file : time.sleep(3)

Then restart rtorrent, add a torrent and see if logs are more verbose.

Edit: if you leave time.sleep(300) you will have to wait 5min after torrent add, because the script waits 5min at the end to handle deletion of files. That's why they seem to be stuck in your system processes.

amlopin commented 4 years ago

Hi again, sorry to be a pain. I tried to run the command and this is the output

python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Doe.2018.720p.WEB.h264-WATCHER test 30F223EE8AC88C5585FFD3D4808739E07B762C44 /home/USER/torrents/rtorrent/Doe.2018.720p.WEB.h264-WATCHER 2018465627 Traceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 100, in cacher.build_cache('checker ' + str(int(time.time()))) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 48, in build_cache list[0]=list[4]-os.stat(list[7]+list[5]).st_size

amlopin commented 4 years ago

I have removed all script and reinstalled. It is very weird because the first 4 torrents are added ok, but after all torrents are added stopped. I am sending a .log The script create all files: *.txt, torrent.py and torrents.py I changed to time.sleep(3) and I see around 20 python processes right now

simonc56 commented 4 years ago

I may have found a bug in cacher.py at line 48, try to change it to : list[0]=list[4]-os.path.getsize(os.path.join(list[7],list[5])) Respect the spaces at beginning of the line.

For the 20 python processes, try the linux command ps | grep python to see the full python command lines.

amlopin commented 4 years ago

Let me see that bug

amlopin commented 4 years ago

all python processes coming from checker.py I have changed that line, removed all .txt and restarted rtorrent First 6 torrents were starting, but after that all new torrents are stopping...

amlopin commented 4 years ago

Hi, this morning I removed rtorrent and your script and reinstalled. I made all changes we´ve been talking here and restarted rtorrent. I added one torrent manually and ok. I turned on autodl and started to work ok. After 6 torrents all is stopping. Also, autodl is matching torrent and sending to rtorrent but it seems that rtorrent does not load them. I have attached a screen and a rtorrent.log. Thank you very much for your support.

simonc56 commented 4 years ago

If a torrent is stuck in stopped state because of the script bugging, it is normal that all next torrents will be stopped too because of the queue system (queue.txt).

To identify the bug of the 6th torrent causing trouble, please do like this again, capture_nothrow in .rtorrent.rc and time.sleep(3) in checker.py. Then send log. The last time you did it was good because we could see a bug in cacher.py.

As always, be sure to restart rtorrent and remove txt files.

amlopin commented 4 years ago

Many thanks again. Top of my .rtorrent.rc is: schedule2 = cleanup, 0, 0, "execute.throw.bg=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/cleaner.py"

method.set_key = event.download.inserted_new, checker, d.stop=, "execute.capture_nothrow=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py,$d.name=,$d.custom1=,$d.hash=,$d.directory=,$d.size_bytes="

I started again. Removed all and reinstalled from scratch. All it is working ok until I activated another filter in autodl, then all torrents stopped. Also I tried to run that command on one of stopped torrents and this is the output:

python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py jayspov.kinuski.1080p.mp4 test E93F0AEEF539459E8C0696E0A91F9C6C04030048/home/USER/torrents/rtorrent/jayspov.kinuski.1080p.mp4 1165192165 Traceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 14, in torrent_size = int(sys.argv[5]) / 1073741824.0 IndexError: list index out of range

LOG: rtorrent.log

simonc56 commented 4 years ago

You just forgot a space between hash and folder.

The problem could be that rtorrent don't have write access in the script folder. Can you give full write access with chmod ?

Also in checker.py can you change at the end : os.remove(subtractions) by

try:
        os.remove(subtractions)
except:
        pass
amlopin commented 4 years ago

You just forgot a space between hash and folder.

Sorry about that, I will try with your others advice, this is the command outcome now:

python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py jayspov.kinuski.1080p.mp4 test E93F0AEEF539459E8C0696E0A91F9C6C04030048 /home/USER/torrents/rtorrent/jayspov.kinuski.1080p.mp4 1165192165 Traceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 100, in cacher.build_cache('checker ' + str(int(time.time()))) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 37, in build_cache enter(identity) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 18, in enter if (running_id == 'cacher' and int(time.time()) - running_start < timedelta(seconds=5)) or (identity == 'cacher' and running_id == 'checker'):

EDIT: I set up chmod 777 to RTORRENT-IMDB-DISK-CHECKER folder, right?

simonc56 commented 4 years ago

yes 777 will be ok. Is there any other line after the one you quote above (if running_id.....) ?

amlopin commented 4 years ago

sorry yes python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py jayspov.kinuski.1080p.mp4 test E93F0AEEF539459E8C0696E0A91F9C6C04030048 /home/USER/torrents/rtorrent/jayspov.kinuski.1080p.mp4 1165192165 Traceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 100, in cacher.build_cache('checker ' + str(int(time.time()))) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 37, in build_cache enter(identity) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 18, in enter if (running_id == 'cacher' and int(time.time()) - running_start < timedelta(seconds=5)) or (identity == 'cacher' and running_id == 'checker'): TypeError: unsupported operand type(s) for -: 'int' and 'str'

simonc56 commented 4 years ago

ok that's another bug, thank you. I will remove timedelta(seconds=5) to become only 5. but i don't understand why it happen now, i will do some tests on my own. I think you are experiencing those bugs because you add many torrents very quickly, that should not be a problem but i admit i never stress tested the script as you do ;)

amlopin commented 4 years ago

Thanks. I changed timedelta and os remove subtractions

Still the same, after few torrents were going ok, then they stopped

python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py GTG.mp4 test AD94A99E9896AC371C4D5B41A84019ECF9896F97 /home/USER/torrents/rtorrent/GTG.mp4 3760003391 Traceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 100, in cacher.build_cache('checker ' + str(int(time.time()))) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 37, in build_cache enter(identity) File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/cacher.py", line 18, in enter if (running_id == 'cacher' and int(time.time()) - running_start < 5) or (identity == 'cacher' and running_id == 'checker'): TypeError: unsupported operand type(s) for -: 'int' and 'str'

simonc56 commented 4 years ago

yes, int(running_start) instead of running_start sorry if (running_id == 'cacher' and int(time.time()) - int(running_start) < 5) or (identity == 'cacher' and running_id == 'checker'):

what is written inside cachelock.txt ?

simonc56 commented 4 years ago

Your rtorrent has system.file.allocate enabled. And it seems you cannot disable it in version 0.9.6.

I will check how to fix that.

amlopin commented 4 years ago

what is written inside cachelock.txt ?

cacher 1591799427

It seems that torrents start to stop when I start to use rutorrent, like pause files, delete files, enable/change filters on irssi...

edit: after all changes, I have run the command on one of stopped torrents and now I havent got any outcome, but the torrent is not starting

amlopin commented 4 years ago

Am working all day, cant recheck anything, have you done any progress? Many thanks

simonc56 commented 4 years ago

I still don't understand why you have cacher in cachelock.txt. It means you launched cacher.py manually or via rtorrent, I don't know why or how...

Anyway some changes are in progress, you can redownload files from github to try, but there is no garantee yet.

amlopin commented 4 years ago

Hi, thanks for your support. I just downloaded the script. On top of .rtorrent.rc how should it be? Because you´ve been told to change it but it remains the old commands. schedule2 = cleanup, 0, 0, "execute.throw.bg=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/cleaner.py" method.insert = stpcheck, simple, d.stop=, "execute.throw.bg=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py,$d.name=,$d.custom1=,$d.hash=,$d.directory=,$d.size_bytes=" method.set_key = event.download.inserted_new, checker, "branch=((and,((not,((d.is_meta)))),((d.state)))),((stpcheck))" I have seen that no .txt are created when new torrents are added

EDIT: going to try with the other command: method.set_key = event.download.inserted_new, checker, d.stop=, "execute.capture_nothrow=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py,$d.name=,$d.custom1=,$d.hash=,$d.directory=,$d.size_bytes="

EDIT2: tried with both, not working. First one, not created any .txt. not doing anything The second one it keeps the first torrent added in queue state, it is stuck and no more torrents are added as you said "all next torrents will be stopped too because of the queue system (queue.txt"

simonc56 commented 4 years ago

Keep in mind that script is made for rtorrent version 0.9.7 at least. For your old rtorrent 0.9.6 use the command line without d.is_meta

I don't know what's wrong, maybe i'll find if you keep sending logs using execute.capture_nothrow

amlopin commented 4 years ago

Ok thanks, it would be like this wihout d.is_meta right?

schedule2 = cleanup, 0, 0, "execute.throw.bg=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/cleaner.py" method.insert = stpcheck, simple, d.stop=, "execute.throw.bg=python,/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py,$d.name=,$d.custom1=,$d.hash=,$d.directory=,$d.size_bytes=" method.set_key = event.download.inserted_new, checker, "branch=((and,((not)),((d.state)))),((stpcheck))"

I reinstalled the script and the top of my .rtorrent.rc is like above. Added some torrents manually, by irssi, removed few, activated more filters and (finger cross) it seems to be working!!!! No queue, paused, stopped torrents... *.txt created and torrents.py torrents.py as well. I will leave it all night to fill the hard drive and hope it will be removing torrents :D Many thanks

simonc56 commented 4 years ago
  1. The line method.insert is ok for all rtorrent version. If you want to read logs of the script and see output of bugs, just change execute.throw.bg to execute.capture_nothrow.

  2. The line method.set_key for rtorrent 0.9.6 need to be (because d.is_meta is not recognize) : method.set_key = event.download.inserted_new, checker, "branch=((d.state)),((stpcheck))"

PS: If you don't want to wait full disk, you can set minimum_space = X in config.py (X is space in GigaBytes).

amlopin commented 4 years ago

Many many thanks. I´ve just changed that lines. Atm it´s working ok. Going to set up minimum_space and see if it removes files. Many thanks for your support, very close to close the issue :D

amlopin commented 4 years ago

Hi again, it stopped to work. Now all added torrents are stopped state. I added a file manually and run the command, it takes forever and not doing anything, I stop with ctrlC this is the outcome:

python /home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py Doe.2018.720p.WEB.h264-WATCHER test 30F223EE8AC88C5585FFD3D4808739E07B762C44 /home/USER/torrents/rtorrent/Doe.2018.720p.WEB.h264-WATCHER 2018465627 ^CTraceback (most recent call last): File "/home/USER/RTORRENT-IMDB-DISK-CHECKER/checker.py", line 96, in time.sleep(0.01) KeyboardInterrupt