murrty / youtube-dl-gui

Download/Convert videos from websites without needing to learn command line
GNU General Public License v3.0
427 stars 45 forks source link

Versions 3.0.0-6 and after cannot store/access yt-dl exe path (probably Win 7's fault) #150

Closed Hypocee closed 1 year ago

Hypocee commented 1 year ago

I attempted to manually upgrade from 2.3.2 to 3.1.1 . Upon encountering this issue I tried going backward a few versions, then started going forward from 2.3.2 . At every attempt I deleted settings.ini and any test yt-dl executable. All first runs properly presented first run dialog boxes. I found that 3.0.0-5 worked as expected and 3.0.0-6 displayed this error chain.

At a guess, your reprioritization of the default yt-dl fork baked in an assumption about the name of the yt-dl executable, and/or some string operation in a path read that's not compatible with Win 7 despite being .NET. String length returns a negative value, possibly an exception code being read as a value.

Affected versions run OK upon answering "yes" to the IP statement and "no" to all settings questions.

Upon entering the settings dialog, the youtube-dl path field is blank (the ffmpeg path field is populated and correct). Clicking ellipsis browse button and selecting the yt-dl exe via text prediction or double-click properly exits the browse dialog and populates the field with the correct path. Clicking Save exits the settings dialog without complaint. However, upon reeentering the settings, the field is blank again. Attempting to download while in this state gets

Beginning download, this box will output progress Youtube-DL has not been found A rescan for youtube-dl was called still couldnt find youtube-dl.

(In later versions the download window looks funky - partially white - while showing this error and the cancel button doesn't work while the X does. It's probably not worth trying to make that window robust against this kind of error state.)

If settings is entered and Use static youtube-dl is turned on, and a path to the yt-dl exe entered, upon clicking Save the program throws an exception window with no title, screwed up formatting and two blank tabs reading:

An unhandled thread exception occurred. The application will exit after closing this dialog.

System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length at System.String.Substring(Int32 startIndex, Int32 length) at youtube_dl_gui.Verification.RefreshYoutubeDlLocation() at youtube_dl_gui.frmSettings.saveSettings() at youtube_dl_gui.frmSettings.btnSettingsSave_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

========== FULL REPORT ========== System.Threading.ThreadExceptionEventArgs ========== END REPORT ==========

========== OS INFO ========== (Please don't omit this info, it may be important) Current version: 3.1.1 Curernt culture: English (United States) System Caption: Microsoft Windows 7 Ultimate Version: 6.1.7601 Service Pack Major: 1 Service Pack Minor: 0 ========== END INFO ==========

The application doesn't exit upon closing that dialog. It returns to the settings. Clicking Save any number of times will pop the same error again.

The yt-dl path is written into the settings.ini immediately upon clicking Save the first time, before the exception. A resulting settings.ini:

[Saved] videoQuality=12 convertType=-1 MainFormSize=262,400 DownloadCustomArguments= CustomArgumentsIndex=-1 [General] UseStaticYtdl=True ytdlPath=C:\Users\Op\Downloads\youtube-dl.exe

If Cancel is used to exit settings and the program is closed and asked to run again, it will display the same error window and refuse to run until settings.ini is deleted or the ytdlPath line is removed from it. Removing only the UseStaticYtdl line has no effect.

If a file named yt-dlp.exe is present upon running an affected release, even a "first" run with no settings.ini, the program will display the same error window and refuse to run.

murrty commented 1 year ago

Sounds like a your environment kind of issue. I've tested it in a virtual machine but could not replicate your issues that you seem to be having.

Hypocee commented 1 year ago

Very well. Thanks for the work attempting to replicate.

murrty commented 1 year ago

I'm re-opening this.

Looking into it with a duplicate issue, I think I found the issue. Do you change the youtube-dl fork when you select the youtube-dl executable? They have to match, as the application extracts application information from the executable.

Because the issue you're having is relating to using the yt-dlp fork (the default fork used), the substring issue seems to be occurring. If you use youtube-dl and not yt-dlp, try selecting youtube-dl as the fork in the download options under the updating tab.

Hypocee commented 1 year ago

You found the problem. I don't like auto-updates in general because I like to minimize the possible reasons things suddenly break, so I didn't care about or set the option which is presented as controlling an auto-updating behavior.

If the fork in the Updating tab is set to match that of the TYDL executable, YT-DL-GUI 3.1.1 will correctly remember a static path, or fill in the default name of the executable from that fork. It will then correctly download from URLs using that executable. (Reasonably enough the fork option must be set in linear time before specifying a path, or the path will be discarded; it's not enough for them to be set in the same settings "session". The options are presumably written and read upon changing pages within settings.)

Good thinking and thanks again, both for making this wonderful tool and for helping me fix my error.