Hellowlol / bw_plex

binge watching for plex
MIT License
367 stars 23 forks source link

Stuck on "Downloading subtitle from PMS" #38

Closed stiangus closed 6 years ago

stiangus commented 6 years ago

Hey! I am somehow still getting stuck when it's trying to download subtitle from PMS.

image

I have been trying to understand more about how this thing works lately, and I got everything else to work fine, with the token and url in the config file and etc. Would like to finally get this part to work now, if possible.

I did pip install -r requirements.txt and it looked like it was downloading a lot of stuff, but I guess something must still be missing since it's stuck on this part.

If I run pip list, this is what I currently have installed. I tried some random stuff like pip install srt and such, but I have no idea how to locate the required one. Or maybe the issue lies somewhere else? Just did a full reinstall with the [all] option and removed everything from my .config/bw_plex folder before trying this.

List output: expand - asn1crypto (0.24.0) - audioread (2.1.5) - backports.functools-lru-cache (1.5) - beautifulsoup4 (4.6.0) - bw-plex (0.0.8.dev10+g1362255, /home/stigus/Documents/plexShowSkip/bw_plex) - certifi (2018.4.16) - chardet (3.0.4) - click (6.7) - configobj (5.0.6) - cryptography (2.1.4) - cycler (0.10.0) - decorator (4.3.0) - docopt (0.6.2) - download (0.3.3) - dtrx (7.1) - enum34 (1.1.6) - et-xmlfile (1.0.1) - f.lux-indicator-applet (1.1.11-pre) - funcsigs (1.0.2) - html5lib (1.0.1) - idna (2.6) - ipaddress (1.0.17) - jdcal (1.4) - joblib (0.11) - keyring (10.6.0) - keyrings.alt (3.0) - kiwisolver (1.0.1) - librosa (0.6.1) - llvmlite (0.23.0) - matplotlib (2.2.2) - numba (0.38.0) - numpy (1.14.3) - odfpy (1.3.6) - opencv-contrib-python (3.4.1.15) - openpyxl (2.5.3) - pexpect (4.2.1) - Pillow (5.1.0) - pip (9.0.1) - PlexAPI (3.0.6) - pocketsphinx (0.1.3) - profilehooks (1.10.0) - psutil (5.4.5) - pycairo (1.16.2) - pycrypto (2.6.1) - pygobject (3.26.1) - pyparsing (2.2.0) - pytesseract (0.2.0) - python-dateutil (2.7.3) - pytz (2018.4) - pyudev (0.21.0) - pyxdg (0.25) - PyYAML (3.12) - requests (2.18.4) - resampy (0.2.0) - scikit-learn (0.19.1) - scipy (1.1.0) - SecretStorage (2.3.1) - setuptools (39.2.0) - singledispatch (3.4.0.3) - six (1.11.0) - SpeechRecognition (3.8.1) - SQLAlchemy (1.2.8) - srt (1.6.0) - subprocess32 (3.5.1) - tablib (0.12.1) - tqdm (4.23.4) - unicodecsv (0.14.1) - urllib3 (1.22) - webencodings (0.5.1) - websocket-client (0.48.0) - wheel (0.30.0) - wsaccel (0.6.2) - xlrd (1.1.0) - xlwt (1.3.0) - youtube-dl (2018.5.26)

I don't really know where to troubleshoot anymore, as everything else seems to work just fine.

stiangus commented 6 years ago

It might actually be stuck somewhere else, previously I was able to remove the words from config.ini and it would jump past the download etc, but now it's stuck even if I do that.

image

When I did that before it would just continue, doing the episode progress check every 8 ish second, and skipping when it was in the right time interval.

I left it like that for 5+ minutes as of right now, and nothing seems to happen.

Starting a new episode does pull it out of whatever is happening, until it gets to the same point on the new episode. image

stiangus commented 6 years ago

I got an error that "sr is not defined" when i tried to manually process a show, seems like it's at the same time the issues arise when i use "watch".

Select episodes: 0
2018-05-29 18:54:50,030 :: bw_plex :: DEBUG :: Getting hashtable
2018-05-29 18:54:50,062 :: bw_plex :: INFO :: Loading existing files in db
2018-05-29 18:54:51,579 :: bw_plex :: DEBUG :: Downloading theme for 1 shows this might take a while..
2018-05-29 18:54:51,594 :: bw_plex :: DEBUG :: Archer (2009) has 0 themes
2018-05-29 18:54:51,594 :: bw_plex :: DEBUG :: Searching search_tunes for Archer (2009) using rk 5875
2018-05-29 18:54:52,710 :: bw_plex :: DEBUG :: http://www.televisiontunes.com/search.php?q=Archer+%282009%29
2018-05-29 18:54:52,963 :: bw_plex :: DEBUG :: Searching youtube for name Archer (2009) rk 5875 save_path /home/stigus/.config/bw_plex/themes url None 
2018-05-29 18:54:56,632 :: bw_plex :: DEBUG :: Download theme using source http://192.168.1.235:32400/library/metadata/5875/theme/1527130301?X-Plex-Token=gPdtZhgWXRSy6XHcPFp1
2018-05-29 18:54:56,633 :: bw_plex :: DEBUG :: calling ffmpeg with ffmpeg -i http://192.168.1.235:32400/library/metadata/5875/theme/1527130301?X-Plex-Token=gPdtZhgWXRSy6XHcPFp1 -ac 1 -ar 11025 -acodec pcm_s16le /tmp/offset_4ELgL3.wav
2018-05-29 18:54:56,761 :: bw_plex :: DEBUG :: Done converted and moved /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav to /home/stigus/.config/bw_plex/themes
2018-05-29 18:54:57,745 :: bw_plex :: DEBUG :: Download theme using source /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612892.wav
2018-05-29 18:54:57,745 :: bw_plex :: DEBUG :: calling ffmpeg with ffmpeg -i /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612892.wav -ac 1 -ar 11025 -acodec pcm_s16le /tmp/offset_UemHu7.wav
2018-05-29 18:54:57,941 :: bw_plex :: DEBUG :: Done converted and moved /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612892.wav to /home/stigus/.config/bw_plex/themes
2018-05-29 18:55:00,020 :: bw_plex :: DEBUG :: Archer (2009) has 2 themes
2018-05-29 18:55:00,020 :: bw_plex :: DEBUG :: Started to process Archer.(2009).s00e04
2018-05-29 18:55:00,021 :: bw_plex :: DEBUG :: Checking if we can reach Archer.(2009).s00e04 directly
2018-05-29 18:55:00,046 :: bw_plex :: DEBUG :: Found /mnt/E/Serier/Archer.S01-S08.480p.WEB.DL.nSD.x264-NhaNc3/Archer/Archer (2009) S00E04 Heart of Archness__ Part I.m4v
2018-05-29 18:55:00,047 :: bw_plex :: DEBUG :: calling ffmpeg with ffmpeg -i /mnt/E/Serier/Archer.S01-S08.480p.WEB.DL.nSD.x264-NhaNc3/Archer/Archer (2009) S00E04 Heart of Archness__ Part I.m4v -ac 1 -ar 11025 -ss 0 -t 600 -acodec pcm_s16le /tmp/offset_3ImhG7.wav
2018-05-29 18:55:02,297 :: bw_plex :: DEBUG :: Done converting /tmp/offset_3ImhG7.wav
Tue May 29 18:55:06 2018 Analyzed #1 /tmp/offset_3ImhG7.wav of 599.307 s to 50127 hashes
2018-05-29 18:55:07,221 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8023 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 187.17605442176873 (03:07) in ended at 212.04462585034014 (03:32)
2018-05-29 18:55:07,221 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8161 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 203.89442176870747 (03:23) in ended at 217.6174149659864 (03:37)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8708 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 206.47183673469388 (03:26) in ended at 215.13287981859412 (03:35)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7476 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 190.0088888888889 (03:10) in ended at 199.2968707482993 (03:19)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8433 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 198.53061224489795 (03:18) in ended at 213.01986394557824 (03:33)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8569 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 203.24426303854875 (03:23) in ended at 210.62820861678006 (03:30)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8295 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 195.74421768707484 (03:15) in ended at 203.4532426303855 (03:23)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7066 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 171.5722448979592 (02:51) in ended at 190.17142857142858 (03:10)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -8127 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 190.77514739229025 (03:10) in ended at 215.41151927437642 (03:35)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7613 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 189.01043083900228 (03:09) in ended at 202.68698412698413 (03:22)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -9118 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 214.43628117913832 (03:34) in ended at 215.20253968253968 (03:35)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7751 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 189.98566893424038 (03:09) in ended at 221.75056689342404 (03:41)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7338 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 195.11727891156463 (03:15) in ended at 197.09097505668936 (03:17)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7990 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 189.01043083900228 (03:09) in ended at 212.0214058956916 (03:32)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7082 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 189.40517006802722 (03:09) in ended at 190.58938775510205 (03:10)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 4 rank 0 aligntime -7032 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav started at 189.01043083900228 (03:09) in ended at 189.40517006802722 (03:09)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Match 5 rank 1 aligntime 603 theme song /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612892.wav started at 38.89342403628118 (00:38) in ended at 125.82893424036281 (02:05)
2018-05-29 18:55:07,222 :: bw_plex :: DEBUG :: Best match was /home/stigus/.config/bw_plex/themes/Archer (2009)__5875__1527612896.wav
2018-05-29 18:55:07,223 :: bw_plex :: DEBUG :: Checking if we can reach Archer.(2009).s00e04 directly
2018-05-29 18:55:07,223 :: bw_plex :: DEBUG :: Found /mnt/E/Serier/Archer.S01-S08.480p.WEB.DL.nSD.x264-NhaNc3/Archer/Archer (2009) S00E04 Heart of Archness__ Part I.m4v
2018-05-29 18:55:07,223 :: bw_plex :: DEBUG :: Calling find_offset_ffmpeg with command ffmpeg -i /mnt/E/Serier/Archer.S01-S08.480p.WEB.DL.nSD.x264-NhaNc3/Archer/Archer (2009) S00E04 Heart of Archness__ Part I.m4v -t 600 -vf blackdetect=d=0.5:pix_th=0.1 -af silencedetect=n=-50dB:d=0.3 -f null -
2018-05-29 18:55:39,149 :: bw_plex :: DEBUG :: final_video [['00:00', '00:02', '00:02'], ['03:06', '03:06', '00:00'], ['03:38', '03:40', '00:02'], ['08:18', '08:20', '00:02']]
2018-05-29 18:55:39,150 :: bw_plex :: DEBUG :: final_audio [['-1:59', '00:02', '00:02'], ['03:38', '03:41', '00:02'], ['04:24', '04:24', '00:00'], ['04:25', '04:25', '00:00'], ['05:14', '05:14', '00:00'], ['05:14', '05:15', '00:00'], ['05:15', '05:16', '00:00'], ['05:17', '05:17', '00:00'], ['07:25', '07:26', '00:00'], ['07:28', '07:28', '00:00'], ['08:18', '08:20', '00:02']]
2018-05-29 18:55:39,150 :: bw_plex :: DEBUG :: fin v [[0.0, 2.04371, 2.04371], [186.269, 186.77, 0.5005], [218.343, 220.887, 2.54421], [498.289, 500.375, 2.08542]]
2018-05-29 18:55:39,150 :: bw_plex :: DEBUG :: fin a [[-0.0173333, 2.04267, 2.06], [218.767, 221.147, 2.38], [264.239, 264.571, 0.332], [265.423, 265.883, 0.46], [314.063, 314.491, 0.428], [314.511, 315.163, 0.652], [315.919, 316.379, 0.46], [317.455, 317.787, 0.332], [445.935, 446.331, 0.396], [448.111, 448.763, 0.652], [498.255, 500.347, 2.092]]
2018-05-29 18:55:39,150 :: bw_plex :: DEBUG :: Matching windows are [['03:38', '03:40', '00:02'], ['08:18', '08:20', '00:02']]
2018-05-29 18:55:39,150 :: bw_plex :: DEBUG :: There are no phrase, add a phrase in your config to check for recaps.
ERROR:root:global name 'sr' is not defined
Traceback (most recent call last):
  File "plex.py", line 384, in prot
    process_to_db(item)
  File "plex.py", line 120, in process_to_db
    recap = has_recap(media, CONFIG['tv'].get('words', []), audio=vid)
  File "/home/stigus/Documents/plexShowSkip/bw_plex/bw_plex/misc.py", line 756, in has_recap
    audio_recap = has_recap_audio(audio)
  File "/home/stigus/Documents/plexShowSkip/bw_plex/bw_plex/misc.py", line 723, in has_recap_audio
    except sr.UnknownValueError:
NameError: global name 'sr' is not defined
2018-05-29 18:55:40,196 :: bw_plex :: DEBUG :: Saving HashTable
DEBUG:bw_plex:Saving HashTable
Hellowlol commented 6 years ago

Crap. My bad. Ill fix that.

Hellowlol commented 6 years ago

git pull should fix that for you. Ill add some more additional logging and a proper exception handler later today (so errors isnt swallowed by watch)

stiangus commented 6 years ago

Awesome, thanks a bunch!

stiangus commented 6 years ago

Allright, it's working better after that fix, but now it's stuck in a loop it seems. process works perfectly without any errors, but when using watch, it loops the current and next episode over and over. So it does everything for the current episode -> next episode -> current... and keeps going like that. So it never gets to the actual skipping part atm.

Edit: The subtitle function seems to be working now though, not getting stuck even when I have the words in config.

Hellowlol commented 6 years ago

Can you post the log?

stiangus commented 6 years ago

Sure thing

Hellowlol commented 6 years ago

Sorry, i havnt added sanitation to the log. Make sure you change auth token :) I edited the post and removed the link to your log

stiangus commented 6 years ago

Yeah, guess it might be bad news sharing that lol. Thanks for fixing. Did you get what you needed though, or should I post a log where I perform another command?

Hellowlol commented 6 years ago

Hmm, i just think it strange that it logs that that westworld s01e01 was added to the db, but on the next run, it says it fail to find it. Can you check the db manually?

After that wipe hashes.pklz the log and media.db, use the watch command let it run for like 5 minutes, control c then poste the log after sanitation! and your config file (remember to remove stuff from there too, just write REMOVED or something on username, password and token) post it to a gist so i dont have to download it :)

Hellowlol commented 6 years ago

Also what client are you using?

stiangus commented 6 years ago

Allright, my media.db has these values: image

Somehow it's re-adding it every time it runs.

I'll get right on that, will post fixed log when it's done :)

Should I input username and pass in config, or is token and url enough? I thought it was fine since I got it running, but if not then I guess that might be the issue.

Edit: Using Chrome web player on this comp to view, can also try with openPHT if needed. Server is running on latest Ubuntu (18.04 I think). Both on the same local network.

Hellowlol commented 6 years ago

I just want to see what settings you have disabled, it quick to disable something you dont want to. url and token is enough but remove the token before you post it here xD.

stiangus commented 6 years ago

Haha, fair enough ^^,

https://gist.github.com/Skedooesh/65803a2f4461035c1d900959042a20f8

stiangus commented 6 years ago

Fresh log after cleaning up everything: https://gist.github.com/Skedooesh/edd5998d877d130eaa6d92e6b10ee9b2

My media.db now looks like this:

image

Hellowlol commented 6 years ago

Thanks its a bug in my sql. Im not that familiar with that. Thanks for the report.

Hellowlol commented 6 years ago

Its "fixed" in the lastest commit. You will need to delete the db before you start the program. Also can you enable check_credits

also can you change your config ini so you values are the same as this?:

[tv]
check_credits = True
check_credits_action = stop
check_credits_start_next_ep = True
check_credits_sec = 120
check_for_theme_sec = 600
check_intro_ffmpeg_sec = 600

[movie]
check_credits = True
check_credits_action = stop
check_credits_sec = 600
check_intro_ffmpeg_sec = 600

That way you can test more features :)

stiangus commented 6 years ago

Awesome, it's working again! :) Sure, i'll test it out and report any oddities. Also, do you have a donate link anywhere? You are on point with the support here, would be nice to contribute a little.

Edit: Found something weird when trying to run it with those settings. https://gist.github.com/Skedooesh/538b7f0269318ab067d188564353e61f

Looks like it's trying to stop it while the theme is running, thinking it is the credits or something? It also didn't try to skip the theme it seems, even though it was in the right time interval.

Also it seems like the process command is having some issues with the preprocessed change.

python plex.py process -n arhcer
2018-05-30 01:02:21,563 :: bw_plex :: DEBUG :: Getting server Servio
Traceback (most recent call last):
  File "plex.py", line 1016, in <module>
    cli()
  File "/home/stigus/.local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/stigus/.local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/stigus/.local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/stigus/.local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/stigus/.local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "plex.py", line 388, in process
    items = se.query(Preprocessed).all()
NameError: global name 'Preprocessed' is not defined
Hellowlol commented 6 years ago

I didn’t plan setting up a donation link before this was really usageble. But my paypal adresse is hellowlol1@gmail.com

I’ll fix the name error. I also expect that some of the other commands broke when I added movie support.

stiangus commented 6 years ago

It's coming along nicely, will contribute a bit. Yeah, I noticed some of the other commands had the same error :)

Hellowlol commented 6 years ago

Can you verify that the credits bug is fixed?

stiangus commented 6 years ago

Yeah, works correctly now, used jump in theme interval and then started to process a new episode when that was done 👌 Process command instead of watch also worked perfect :)

Hellowlol commented 6 years ago

Closing this as your issue seemed to be solved. If you have any suggestions/improvements feel free to chip in. :)