pystardust / ani-cli

A cli tool to browse and play anime
GNU General Public License v3.0
7.92k stars 543 forks source link

mpv is not recieving a (correct) link to play? #192

Closed dconixDev closed 2 years ago

dconixDev commented 2 years ago

Specs

$ setsid -V
setsid from util-linux 2.37.2

$ grep --version
grep (GNU grep) 3.7

$ sed --version
sed (GNU sed) 4.8

$ curl --version
curl 7.80.0

$ uname -o -r -v
5.15.7_1 #1 SMP Thu Dec 9 12:44:26 UTC 2021 GNU/Linux (Void Linux)

$ mpv --version
mpv 0.34.0 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
 built on Sat Nov  6 21:13:12 UTC 2021
FFmpeg library versions:
   libavutil       56.70.100
   libavcodec      58.134.100
   libavformat     58.76.100
   libswscale      5.9.100
   libavfilter     7.110.100
   libswresample   3.9.100
FFmpeg version: 4.4.1

The Issue

I couldn't reproduce the issue with other anime except for the one cited below, dub version has the same problem Senpai ga Uzai Kouhai no Hanashi

I have a problem possible duplicate of #175 and/or #106 . As suggested on the latter issue I added --log-file=debug.log to line 280 of the script and have attached the files to this issue, here are the highlights from those files:

As of 9/12/21 the episodes up to 4 were working but the next day (didn't update ani-cli) it stopped working, I updated ani-cli but it wasn't working still. These errors are present ONLY on episodes below (including) 8 said anime

[   0.045][e][file] Cannot open file '': No such file or directory
[   0.045][e][stream] Failed to open .

As for this error I'm assuming the website isn't getting scraped correctly and no link is retrieved.

These errors are present on the other two episodes (9 and 10)

[   1.215][e][stream] Failed to open https://www16.anicdn.stream/astream/0455eee500c6dee7ca2530ecc786f8db/senpai-ga-uzai-kouhai-no-hanashi-episode-9.1638649695..m3u8.
[   1.215][v][cplayer] Opening failed or was aborted: https://www16.anicdn.stream/astream/0455eee500c6dee7ca2530ecc786f8db/senpai-ga-uzai-kouhai-no-hanashi-episode-9.1638649695..m3u8
[   1.216][v][cplayer] Running hook: ytdl_hook/on_load_fail
[   1.216][v][ytdl_hook] full hook 
[   1.216][d][global] config path: 'yt-dlp' -/-> '/home/user/.config/mpv/yt-dlp'
[   1.216][d][global] config path: 'yt-dlp' -/-> '/home/user/.mpv/yt-dlp'
[   1.216][d][global] config path: 'yt-dlp' -/-> '/etc/mpv/yt-dlp'
[   1.216][v][ytdl_hook] No youtube-dl found with path yt-dlp in config directories 
[   1.216][d][ytdl_hook] Running: yt-dlp --no-warnings -J --flat-playlist --sub-format ass/srt/best --format bestvideo+bestaudio/best --all-subs --no-playlist -- https://www16.anicdn.stream/astream/0455eee500c6dee7ca2530ecc786f8db/senpai-ga-uzai-kouhai-no-hanashi-episode-9.1638649695..m3u8 
[   1.216][d][cplayer] Run command: subprocess, flags=64, args=[args="yt-dlp,--no-warnings,-J,--flat-playlist,--sub-format,ass/srt/best,--format,bestvideo+bestaudio/best,--all-subs,--no-playlist,--,https://www16.anicdn.stream/astream/0455eee500c6dee7ca2530ecc786f8db/senpai-ga-uzai-kouhai-no-hanashi-episode-9.1638649695..m3u8", playback_only="yes", capture_size="67108864", capture_stdout="yes", capture_stderr="yes", detach="no", env="", stdin_data="", passthrough_stdin="no"]
[   7.542][v][ytdl_hook] Found youtube-dl with path yt-dlp in PATH 
[   7.542][e][ytdl_hook] ERROR: Unable to download webpage: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[   7.542][e][ytdl_hook] Traceback (most recent call last):
[   7.542][e][ytdl_hook]   File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
[   7.542][e][ytdl_hook]     return _run_code(code, main_globals, None,
[   7.542][e][ytdl_hook]   File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
[   7.542][e][ytdl_hook]     exec(code, run_globals)
[   7.542][e][ytdl_hook]   File "/usr/local/bin/yt-dlp/__main__.py", line 19, in <module>
[   7.542][e][ytdl_hook]   File "/usr/local/bin/yt-dlp/yt_dlp/__init__.py", line 750, in main
[   7.542][e][ytdl_hook]   File "/usr/local/bin/yt-dlp/yt_dlp/__init__.py", line 740, in _real_main
[   7.542][e][ytdl_hook]   File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 2884, in download
[   7.542][e][ytdl_hook]   File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 2908, in sanitize_info
[   7.542][e][ytdl_hook] AttributeError: 'NoneType' object has no attribute 'setdefault' 
[   7.542][e][ytdl_hook] youtube-dl failed: unexpected error occurred 
[   7.543][v][cplayer] finished playback, loading failed (reason 4)

I'm assuming the URL is not getting scraped correctly since it has "..m3u8" as the extension with two dots(.). [ 1.215][e][stream] Failed to open https://www16.anicdn.stream/astream/0455eee500c6dee7ca2530ecc786f8db/senpai-ga-uzai-kouhai-no-hanashi-episode-9.1638649695..m3u8.

I thought other other ongoing anime would have this problem but it didn't seem like it.

debug_ep8-.log debug_ep9+.log

Rendevior commented 2 years ago

Maybe caused by typos in Script, there must be a specific quality there among those 2 dots (.1080.m3u8) try git pull if it can solve your problem.

Dink4n commented 2 years ago

Possible duplicate of #139 This was fixed in 1a1909b1f7bced503cd9173e433d9a712eae137c

Rasmus-Bertell commented 2 years ago

I have this same error with the newest version from AUR.

 176   │ [   0.028][d][ffmpeg] tcp: Starting connection attempt to 45.57.233.82 port 443
 177   │ [   0.215][d][ffmpeg] tcp: Successfully connected to 45.57.233.82 port 443
 178   │ [   1.039][w][ffmpeg] https: HTTP error 404 Not Found
 179   │ [   1.039][e][stream] Failed to open https://www16.anicdn.stream/astream/c751bab1939a2b83020565e1ac242896/one-piece-episode-1003.1639275080..m3u8.
 180   │ [   1.039][v][cplayer] Opening failed or was aborted: https://www16.anicdn.stream/astream/c751bab1939a2b83020565e1ac242896/one-piece-episode-1003.1639275080..m3u8
dconixDev commented 2 years ago

@Dink4n I did check all the "fixes" on issue #139 but nothing worked, and yes I am running the latest version of the master branch, I am 100% sure that your commit is on my file. The fix for "..m3u8" did not work so I added video_url=$(echo $video_url | sed -r 's/\.\./\./g') right before calling for setsid -f $player_fn ... and it worked but only for episodes 9-10.

As for episodes 8 and below here is what I tried:

I attached the modified ani-cli with the echo statements, but basically i just put echo on functions that were extracting video_url and as it seems the first sed statement on the function get_links() is not working as it should:

    video_url=$(curl -s "$embedded_video_url" |
    sed -n -E '
        /^[[:space:]]*sources:/{
        s/.*(https[^'\'']*).*/\1/p
        q
        }
        ')

this is returning nothing.

The output of the modified ani-cli:

Getting data for episode 8
<< open_episode embedded: https://gogoplay1.com/embedplus?id=MTc1MzUz&token=27jLBrAG6OmQ1Zd2ibVuog&expires=1639408320
<< open_episode video:
>> Get_links: https://gogoplay1.com/embedplus?id=MTc1MzUz&token=27jLBrAG6OmQ1Zd2ibVuog&expires=1639408320
>> Get_links video_url:
>> Get_links tmp_url:
>> Get_links video_url:
>> Get_links video_quality:
<< open_episode video2:
>> Get_links: https://gogoplay1.com/embedplus?id=MTc1MzUz&token=27jLBrAG6OmQ1Zd2ibVuog&expires=1639408320
>> Get_links video_url:
>> Get_links tmp_url:
>> Get_links video_url:
>> Get_links video_quality:

ani-cli.txt

Rasmus-Bertell commented 2 years ago

I also had some moderate success with video_url=$(echo $video_url | sed -r 's/\.\./\./g') but there are still episodes not working, like Steins;Gate episode 1.

debug.log

dconixDev commented 2 years ago

@RasmusBertell I checked your debug.log and you had the same error

[   0.023][e][file] Cannot open file '': No such file or directory
[   0.023][e][stream] Failed to open .

as me (for episodes 8 and below), I didn't see this error being mentioned elsewhere and no real solutions are available, someone with REGEX knowledge needs to look at it.

Edit: The video is being played from StreamSB servers and I didn't find a way to get an m3u8 link from them. The URL is sbplay2.com/.... though there is a "download" button so the devs might be able to do something with that.

dconixDev commented 2 years ago

EPISODE 9-10 ISSUE I was looking at the HTML file for the embedded player and I found out that as @TheGlockMisc mentioned there is no quality specified

sources:[{file: 'https://www16.anicdn.stream/astream/0455eee500c6dee7ca2530ecc786f8db/senpai-ga-uzai-kouhai-no-hanashi-episode-9.1638649695.m3u8',label: 'hls P','type' : 'hls'},]

thus outputting the double dotted link at the end "..m3u8"

Rasmus-Bertell commented 2 years ago

Debugging this it seems that some episodes play in an iframe and the script can't handle that, though I'm not entirely sure.

Relevant function is get_links ().

Dink4n commented 2 years ago

Replace the quality selecting code https://github.com/pystardust/ani-cli/blob/1a1909b1f7bced503cd9173e433d9a712eae137c/ani-cli#L125-L128 With

printf '%s' "$video_url"

The video url used to contain all the video qualities

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=436422,RESOLUTION=640x360,NAME="360p"
ep.1.1605560765.360.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=690059,RESOLUTION=854x480,NAME="480p"
ep.1.1605560765.480.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1550688,RESOLUTION=1280x720,NAME="720p"
ep.1.1605560765.720.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2790544,RESOLUTION=1920x1080,NAME="1080p"
ep.1.1605560765.1080.m3u8

but now it doesn't.

port19x commented 2 years ago

Closed in favor of #202