Author Topic: is it possible to check video artwork file exist or not  (Read 3237 times)

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
is it possible to check video artwork file exist or not
« on: December 20, 2021, 08:50:26 PM »
I would to write a function to check video artwork file exist or not. Anyone know how to do it? Thanks.

if video file exit {
do something
}

Mark Norville

  • Sr. Member
  • ****
  • Posts: 233
    • View Profile
Re: is it possible to check video artwork file exist or not
« Reply #1 on: January 06, 2022, 04:59:08 AM »
I honestly do not have a clue, but sadly not many people seem to answer on the forum.

However, I am going to say, think about it logically you have 100,000 games as an example.

That is a lot of checking and a lot of processing power, if you have 80 systems and 100 collections as an example, that is a lot to go through.

As a non techie, I would say that this would not be worth the time or effort to try and code for it.

However, hopefully someone might be able to answer your question that wears a techie hat. I just see something does not have a video, and put one in.

Regards

Mark
Well I am back a new PC I7 4790K, 780 TI, 16 Gigs, Windows 10. Hopefully will get delivered at weekend.

Computer Specs : I7 3770K, 780 TI, 16 Gigs, Win 10
HD Specs : 1 x 1 TB SSD + 4 x 8 TB = 33 TB (fullish)
First system : ZX81 (Yes I am an old fart)
PS Network : MarkNorvile
Xbox : Mark Norville

Hojo

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
Re: is it possible to check video artwork file exist or not
« Reply #2 on: February 03, 2022, 08:28:11 AM »
Do you want to do this within attractmode? or is this for an external application?

Sake

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: is it possible to check video artwork file exist or not
« Reply #3 on: February 22, 2022, 10:58:44 PM »
I'm working on a layout and needed something similar. Here's a modified version that could work for you. Note: I modified this from my original code and didn't test run it, I may have typos but the core logic is the same.
The function GetArtOfType() will return a filename if it matches your criteria or empty string if nothing is found for example:

local fileName = GetArtOfType(0, "");
fileName could equal an asset name found in the "video" subfolder with any extension .mp4, .avi, .mkv etc...

local fileName = GetArtOfType(0, ".mp4");
Performs the same search but only return a filename if it contains ".mp4" in the name.

Code:
// Configure the root art folder such as /emu/artwork you can get the value from UserConfig or hard code if you like
local g_baseArtFolder = my_config["baseArtFolder"];
// List of media folders that can be searched. The index parameter in GetArtOfType refers to this list
local g_mediaFolders = ["video","snap","flyer"];
// Store files in found in folders to avoid performing the directory search each time
local g_assetFileNames = [];

/////////////////////////////////////////////////////////////////////////
// Get the asset file of a given type if it exists
//
// \param mediaIndex - Index into your media folder list to use for lookup
// \param extension - Specific file extension if desired, otherwise first match will be returned
//
/////////////////////////////////////////////////////////////////////////
function GetArtOfType(mediaIndex, extension)
{
   // Note this assumes assets are stored in system folders such as /emu/artwork/atari2600/video
   // where the system name comes from the emulator name you use in AM. If you do not use that
   // structure edit below to match
   local baseName = g_baseArtFolder + "/" + fe.game_info(Info.Emulator) + "/" + g_mediaFolders[mediaIndex];
   local gameName = fe.game_info(Info.Name) + ".";
   
   // Only get the directory listing 1 time
   if (g_assetFileNames[mediaIndex] == null)
   {
      g_assetFileNames[mediaIndex] = DirectoryListing(baseName).results;
   }
   
   // Determine if a file in the target folder matches the active game and optionally the desired extension
   foreach (filename in g_assetFileNames[mediaIndex])
   {
      // Find any file that has the game name in it
      if (filename.find(gameName) != null)
      {
         if (extension.len() > 0)
         {
            if (filename.find(extension) != null)
            {
               return filename;
            }
         }
         else
         {
            return filename;
         }
      }
   }
   
   return "";
}

Mark Norville

  • Sr. Member
  • ****
  • Posts: 233
    • View Profile
Re: is it possible to check video artwork file exist or not
« Reply #4 on: February 22, 2022, 11:54:42 PM »
I do everything by hand but it was easy to just modify the basic skin and have it so that artwork is shown in location

I have not completed this fully, I got it working for what I wanted and needed. As I am using cabinets, it will show the cabinet, the marquee and also video snap so you can have a rough idea of what it will look like.

I have all of the information showing, especially the rom file name, that way if I think that the game is rubbish and I do not want it, I can simply go into that directory and delete gamesucks.zip

You would have to modify it to show whatever artwork you want, but it is easy and straight forward enough to do anyway.

Here is a short demo of it in action https://www.youtube.com/watch?v=s0w9gw6ytz4 18 seconds long

Regards

Mark
« Last Edit: February 22, 2022, 11:59:40 PM by Mark Norville »
Well I am back a new PC I7 4790K, 780 TI, 16 Gigs, Windows 10. Hopefully will get delivered at weekend.

Computer Specs : I7 3770K, 780 TI, 16 Gigs, Win 10
HD Specs : 1 x 1 TB SSD + 4 x 8 TB = 33 TB (fullish)
First system : ZX81 (Yes I am an old fart)
PS Network : MarkNorvile
Xbox : Mark Norville

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: is it possible to check video artwork file exist or not
« Reply #5 on: February 23, 2022, 02:09:13 AM »
Thank you all support  :)