CC snippet - Video length

Discuss and share scripts and script files...
G_Mugford
Posts: 12
Joined: 22 Feb 2015 23:32

Re: CC snippet - Video length

Post by G_Mugford » 28 Feb 2019 12:33

highend wrote:
28 Feb 2019 12:05
even the entry for an AVI file of an old Lone Ranger TV episode was 00:00:00.
Select that file, execute this from the address bar and post the output:
text "_" . property("System.Media.Duration", <curitem>) . "_";
More action. The result was:
_13641640000_

I assume this is a return of some number of microseconds and SHOULD convert into a Hrs:Mins:Secs format through the script. And if so, why is it returning the 00:00:00? I'm completely new to XYS scripting, although I program in Pascal and have SOME experience with AHK, so I'm not oblivious to the general practices of programming. I know spaces/tabs are important to XYS scripting. I copied and pasted and did as little futzing as I could with the original code you posted. I did notice the original path was not drive specific, but I assume my including the whole path was not an issue. That said, I didn't truly examine the 'replace the path' concept for the variable. I assumed there were internal replacement vars within the alphanumeric string. I only replace the end part with my exact path. It LOOKS wrong to me, but I've read enough to know you trust a Highend script. Period. So, no fussing. I did make the change Jupe suggested. Before the change in K-Lite to the older 32-bit version.

And another admission... XYplorer is my tertiary file manager and has been neglected. I'm an old Xplorer2 guy and have Q-Dir available when I want LOTS of file management windows open. I'm looking at the looming Window10 invasion of the house and I know the Xplorer2 version I have a license for won't make that journey well. So, I'm looking at XYplorer with a little more interest of late. I'm impressed with the ability to squash scripts into minimal number of lines, but the notation is enough different that I'm having trouble following some of the stuff. Just an old man struggling with new things.

At any rate, thanks again for getting BACK involved. This looks like a good community. GM

Last NOTE: (Honest [G]) Is there ANY way to change the default hotkey assignments in XYplorer?? I'd use it more if the hotkeys within it didn't do such DIFFERENT things as in Xplorer2. Dangerously different things. And the middle click of a file needs to be a select toggle when in the file pane for me to EVER be happy switching over. Might not live lone enough to actually get accustomed to the differences if FORCED to learn them.

highend
Posts: 8157
Joined: 06 Feb 2011 00:33

Re: CC snippet - Video length

Post by highend » 28 Feb 2019 12:36

why is it returning the 00:00:00
Because you put the full snippet into the script box of the custom column like I explained in my last posting...
Is there ANY way to change the default hotkey assignments in XYplorer
Menu - Tools - Customize Keyboard Shortcuts...?
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

G_Mugford
Posts: 12
Joined: 22 Feb 2015 23:32

Re: CC snippet - Video length

Post by G_Mugford » 28 Feb 2019 12:43

highend wrote:
28 Feb 2019 12:17
This is NOT the script, this is a snippet that fills all items for that custom column definition^^

This is the script:

Code: Select all

      $nsecs = property("System.Media.Duration", <cc_item>);
  
      // Use mediainfo for unknown codecs ($nsecs is empty!)
      if ($nsecs == "") {
          $mediaInfo = "<xydrive>\Tools\@Command Line Tools\MediaInfo\MediaInfo.exe";
          $length = regexreplace(runret("$mediaInfo --Inform=General;%Duration/String3% ""<cc_item>"""), "\.\d*\r?\n");
          return $length;
  
      // Use system properties for known codecs
      } else {
          // To get real seconds from nanoseconds, multiply the value with 0.0000001
          $secs = round($nsecs * 0.0000001);
  
          // Calculate length
          // Do we have a playtime in hours?
          $hours = $secs / 3600;
          if ($hours >= 1) {
              $hours = format(regexmatches($hours, "^\d+"), "00");
              $secs  = $secs - $hours * 3600;
          } else { $hours = "00"; }
          // Playtime only in minutes
          $mins = $secs / 60;
          if ($mins >= 1) {
              $mins = format(regexmatches($mins, "^\d+"), "00");
              $secs = $secs - $mins * 60;
          } else { $mins = "00"; }
          // -> Playtime is only seconds
          // Nothing to calculate here any more
          return $hours . ":" . $mins . ":" . format($secs, "00");
      }
And sorry, but this is total bs:

Code: Select all

$mediaInfo = "<xydrive>\Tools\@Command Line E:\apps\media\mediaInfo\CLI\MediaInfo.exe";
It must be:

Code: Select all

$mediaInfo = "E:\apps\media\mediaInfo\CLI\MediaInfo.exe";
I apologize for riling you up Highend. I copied the snippet as in the first response in this thread. Not knowing XYS scripting, I didn't know to excise the excess data in the snippet. As I just explained, what I did to the path for $mediaInfo LOOKED wrong to me, but I went with what I thought the replacement was supposed to be. My error, so sorry.

Having clipped the snippet correctly, I now have a working Video Length column. This is a mark for increased use of XYplorer. Which leaves me with a question: Am I stuck with this old 32 bit version of K-Lite? Can I install the latest version outside of the program files hive? It's not like the old version doesn't do the job. But I'm usually an instant updater for most programs for fear of a vulnerability sneaking by me.

Once again, thanks to EVERYBODY who took their time to help out a newbie. GM

highend
Posts: 8157
Joined: 06 Feb 2011 00:33

Re: CC snippet - Video length

Post by highend » 28 Feb 2019 12:45

Would you please read the answers you get in this thread?
E.g.: viewtopic.php?p=167796#p167796
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

G_Mugford
Posts: 12
Joined: 22 Feb 2015 23:32

Re: CC snippet - Video length

Post by G_Mugford » 28 Feb 2019 12:53

highend wrote:
28 Feb 2019 12:36
why is it returning the 00:00:00
Because you put the full snippet into the script box of the custom column like I explained in my last posting...
Is there ANY way to change the default hotkey assignments in XYplorer
Menu - Tools - Customize Keyboard Shortcuts...?
The issue is handling mouse buttons. I toggle file selection with middle clicks. There are other mouse combinations that I can't get to. But that selection toggle is huge hurdle number one and the reason I mothballed XYplorer until doing my recent re-install of the latest versions of my software set. There's other differences in the way functions are handled for things, like Batch Renaming for one. But at least I can reassign the rename function to Alt-F2 and then do the batch rename to F2. That's counter to Windows standard, but it's the standard for the way I operate with file managers. Nice to know I can swap them around. I remember an issue the last time I looked. But I have no details, so it doesn't matter. Still, that mouse issue probably means scripting.

Something to do when the basketball game gets boring.

Thanks, GM

G_Mugford
Posts: 12
Joined: 22 Feb 2015 23:32

Re: CC snippet - Video length

Post by G_Mugford » 28 Feb 2019 12:56

highend wrote:
28 Feb 2019 10:45
Em, what?

http://files2.codecguide.com/K-Lite_Cod ... 5_Mega.exe

This automatically installs 32 and 64-bit codecs (on a 64-bit OS), unless you
tell it specifically to leave out 32-bit ones...
Will read the page again when I'm less sleep deprived. I was supposed to be napping an hour ago. Thankfully, I stayed up and got the help I needed for the issue.

Sorry for making it all so arduous. Appreciate the willingness to stick it out. GM

Post Reply