Jump to content
LaunchBox Community Forums

Recommended Posts

Posted

Hi there,

I have a plugin (Vidsnap Scraper) that downloads game snaps and places them in the Videos directory. It generally works well, but I’ve encountered a user who has their LaunchBox installation on an external drive and is experiencing some issues.

To determine the LaunchBox path, I use Reflection and then append "\Videos\filename.ext" as follows:

private string launchBoxDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly()?.Location) ?? string.Empty;

This usually results in a path like:

C:\Users\Username\LaunchBox\Core\Videos\gamename.mp4

However, I’ve noticed that the Videos folder inside Core is actually a link to the Videos folder in the main LaunchBox directory. This link seems to be created when LaunchBox starts and removed when it closes.

Interestingly, on an older thumb drive, LaunchBox doesn’t create a link but instead generates a physical folder, whereas on another thumb drive, it works correctly. I suspect this is causing issues with my plugin.

 

Would removing \Core from the LaunchBox directory path be a viable solution, or could this introduce potential issues in the future?

 

Any help would be greatly appreciated!

 

Posted

There is no need for you to ever manually be creating the path, and doing so like this would ignore the users folder settings if they store their videos somewhere that isn't default. You should be using IGame.GetNextVideoFilePath(videoType, extension) call to get the appropriate file path to move/copy the file to.

Posted

Hi there, thanks for the response!

however, I'm not sure I fully understand. Sorry to be a noob at this, and apologies for my lack of knowledge in this regard.

So IGame.GetNextVideoFilePath gives a string to the lines of "Videos\<platform>\<gamename>-01",

I use yt-dlp to dowload the videos, and it requires an output path. If I give it this, it will create a folder Videos\<platform>\<gamename>-01 from its root (which in this case is the plugins folder).

How do I get from there to the actual video folder without specifying the full path?

Sorry if my explanation is poor.

Posted

IGame.GetNextVideoFilePath I believe gives you and absolute path (vs a relative path).  Since you're using videos, specify the parameter ".mp4". (include the period)

string path = selectedGame.GetNextVideoFilePath("", ".mp4");

If that game already has a video (<gamename>-01.mp4), path will result in D:\LaunchBox\Videos\<platform>\<gamename>-02.mp4.  (it's like magic :))

If you want to save it as a Trailer video, add that parameter.

string path = selectedGame.GetNextVideoFilePath("Trailer", ".mp4");

If for some reason that "Trailer" subfolder didn't already exist, the above will create the folder. (more magic)

D:\LaunchBox\Videos\<platform>\Trailer\<gamename>-02.mp4.

 

I didn't test GetNextVideoFilePath(). But I did test GetNextAvailableImageFilePath() and the above (absolute path, incrementing the file # and creating the folder) is how it worked with it.  Since both those calls were added to the API at the same time, I'd image they work the same.

 

If it is only giving you a relative path (like you show), just convert the result to an absolute.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...