INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 6   Go Down

Author Topic: pscriptor.pl: a general purpose scriptable MC field manipulator + utility  (Read 100891 times)

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

I've posted version 1.12, which fixes a few issues and adds a new scriptlet TestFile which will test/verify some media files.

Version 1.12
    - New: scriptlet FileTest verifies media files.  See scriptlet for supported file types and
      instructions.  More file types will be added as requested (and as verification tools are
      shown to be reliable).
    - Fix: missing -f is now reported instead of silently doing nothing.
    - Fix: several fixes for scriptlets GetCoverArtInfo and AcousticFingerprint: 1. conditionally
      use Win32 on Win32 platforms; 2. failure to use the non-ansi filename when an ANSI filename
      was unavailable;  3. failure to increment a file count used for debugging.
    - Fix: GetCoverArtInfo debug message used quotes ' instead of ", preventing interpolation.

The TestFile scriptlet currently supports file types of flac and m4a.  See the scriptlet for installation instructions.  Example usage:

   perl pscriptor.pl -c pscriptor-config.txt  -E TestFile -f comment

where any failed results of the test will be placed in the Comment field.  Unsupported file types will be ignored, and successful verification will not write any results to the Comment field.

See also:

   http://yabb.jriver.com/interact/index.php?topic=88717.0
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Hello MrC,

I am trying to run WhichPlaylists and I get this error



perl pscriptor.pl -c pscriptor-config.txt -E WhichPlaylists -f Playlists_Paths
Uncaught exception from user code:
        send_items: MCWS write failed:
        http://localhost:52199/MCWS/v1/File/SetInfo?Value=%20-%20Tango%5C%20-%20Milongas%20Cl%5CC.%20Modern%20*%5CSassone%20Florindo%20%20St%5CTango%20(1)%5CMedium%5CDramatic&Field=playlists_paths&FileType=Filename&File=(Install%20Drive)%3A%5Ct%5Cmus
ic%5Cfiloi%5C2%5CFlorindo%20Sassone%20-%20214%20Registros%5CFlorindo%20Sassone-Viruta.wav
        500 Internal server error
        <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
        <Response Status="Failure"/>
        MCUtils::MCWS::send_items('MCUtils::MCWS=HASH(0x243a60c)', 'REF(0x243501c)') called at MCUtils/MCWS.pm line 55
        MCUtils::MCWS::send('MCUtils::MCWS=HASH(0x243a60c)', 'ARRAY(0x24373f4)') called at pscriptor.pl line 155


Is there something that I am doing wrong?

Thanks

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

The error is:

  send_items: MCWS write failed:

so this indicates that MCWS doesn't like the URL for some reason.    I tried the same URL, but with a different file name, C:\1.mp3 and this worked.  Then I tried a WAV file with C:\1.wav, and that worked.

So the problem is likely something else about your path that MCWS doesn't like, probably the (Install Drive):\ part, but I'm not sure.  I'm not setup here to test a portable installation to see how MC handles that.  Have you successfully used pscriptor with other paths on (Install Drive):\ before?
Logged
The opinions I express represent my own folly.

arin

  • Junior Woodchuck
  • **
  • Posts: 97

Sorry to bother you MrC,
but I'm trying to get pscriptor running on mac and I got some problems 'caused, I think, about missing resources.
I've tried to install ActivePerl for mac but it didn't solve the problem.

Could you guide me to install everything pscriptor requires to run on mac?


Thanx a lot!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Ok, great question, and I knew someday, someone would ask.

I'll state up front, some will find this too much trouble...

First, I've never used ActivePerl on the Mac (in fact, I can think there are some cases where ActivePerl may not work with pscriptor and other Perl scripts I've created).  There's no reason too, as OS X includes Perl (and I will spend no time working out issues with ActivePerl on the Mac).  The only thing you'll be missing are some of the CPAN modules that pscriptor and the scriptlets use.  So these have to be installed.

Now, there are a couple of ways to install modules, often times they are trivial, but require OS X development tools such as a compiler, and this part is the drag... because it drags in some large binaries which you're likely to never use.  And building CPAN modules leaves users lost when the build fails.

So the better approach is to use pre-built and pre-tested tool environments.  There are two external tool kits that many folks use when they want to add additional tools to their OS X system.  Folks pick one or the other, whichever suits their needs/tastes (I use MacPorts):

   MacPorts: https://www.macports.org/
   Fink: http://www.finkproject.org/

There is also the BSD ports collection, but I won't suggest that, as it is more complicated than most uses will want to deal with.

With either of the above, you'll need to install:

   - Apple's Xcode
   - Apple's Command Line Developer Tools (can be installed via Xcode above)

This will use a few gigabytes of your disk.

I'll continue describing more if you are still interested...  
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

The error is:

  send_items: MCWS write failed:

so this indicates that MCWS doesn't like the URL for some reason.    I tried the same URL, but with a different file name, C:\1.mp3 and this worked.  Then I tried a WAV file with C:\1.wav, and that worked.

So the problem is likely something else about your path that MCWS doesn't like, probably the (Install Drive):\ part, but I'm not sure.  I'm not setup here to test a portable installation to see how MC handles that.  Have you successfully used pscriptor with other paths on (Install Drive):\ before?



I think that it had worked well previouslly with (install drive) paths, but I can't be totally sure.

I tried the DateParse script with another file which doesn't have the (install drive) path but got similar results. I checked and the file is not "read only".


perl pscriptor.pl -v -c pscriptor-config.txt -E DateParse -f "Filename (name)"::Date_Recorded
File: X:\t\2. Epoca de Oro\Alfredo De ├Βngelis\Cantores\Juan Carlos Godoy\Entre tu amor y mi amor(J.Pomati,L.D.V├σlez) - De ├Βngelis, J.C.Godoy [18.8.1959].mp3
DateParse: parse_format error: Date not fully specified
        in(filename (name)): 'Entre tu amor y mi amor(J.Pomati,L.D.V├σlez) - De ├Βngelis, J.C.Godoy [18.8.1959].mp3'
        old(date_recorded): ''
        new(date_recorded): '1959'
Uncaught exception from user code:
        send_items: MCWS write failed:
        http://localhost:52199/MCWS/v1/File/SetInfo?Value=1959&Field=date_recorded&FileType=Filename&File=X%3A%5Ct%5Cmusic%5Cfiloi%5CTango%20Mike%5C2.%20Epoca%20de%20Oro%5CAlfredo%20De%20%C3%81ngelis%5CCantores%5CJuan%20Carlos%20Godoy%5CEntre%20tu%20
amor%20y%20mi%20amor(J.Pomati%2CL.D.V%C3%A9lez)%20-%20De%20%C3%81ngelis%2C%20J.C.Godoy%20%5B18.8.1959%5D.mp3
        500 Internal server error
        <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
        <Response Status="Failure"/>
        MCUtils::MCWS::send_items('MCUtils::MCWS=HASH(0x22fa12c)', 'REF(0x340232c)') called at MCUtils/MCWS.pm line 55
        MCUtils::MCWS::send('MCUtils::MCWS=HASH(0x22fa12c)', 'ARRAY(0x22f6f04)') called at pscriptor.pl line 155


When running the WhichPlaylists script for this file it just doesn't return any results or errors.
I added "-v" and I got "Null value returned from script", although I can see that the file is in playlists.
Logged

arin

  • Junior Woodchuck
  • **
  • Posts: 97

Thank you!
I installed Xcode before I had a try with ActivePerl; I thought ActivePerl could help me getting the missing resources...
In the next days I'll try installing MacPorts and the Command Line Developer Tools...hoping not to drown in all this code! ;)
In that case I'll ask you for some more help.

In the meantime if you've got some more pearls about perl you could share with a complete dumb newbie, you're really very welcome!!!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

This time you got a different error:

   DateParse: parse_format error: Date not fully specified

The reason for this is that your dates are using . (dot) as a separator and not - (dash), and I intentionally am only checking for dash to minimize chances for incorrect date matching.

Also, there is no pattern in the script to detect for the dd-m-yyyy in any case, which you can add to the @date_formats array, somewhere near the top:

        '(?:^|\D)%d-%f-%Y(?:\D|$)', # DD-M-YYYY

If you'd like, I can make the date separator configurable, or you can use an expression column now to replace dot with dash:

   replace([filename (name)], ., -)

and use the expression column as the input field.

To test against your (install path) file, you might test with a simpler, surer scriptlet such as NameCase.
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Thank you!
I installed Xcode before I had a try with ActivePerl; I thought ActivePerl could help me getting the missing resources...
In the next days I'll try installing MacPorts and the Command Line Developer Tools...hoping not to drown in all this code! ;)
In that case I'll ask you for some more help.

In the meantime if you've got some more pearls about perl you could share with a complete dumb newbie, you're really very welcome!!!

Great, and You're Welcome.

Be sure to follow the instructions @ MacPorts, items 1 through 3 mentioned under Quickstart, which are expanded further under Installing MacPorts items numbered 1, 2, and 3:

   https://www.macports.org/install.php

You'll want to install from the pkg format for your version of OS X.

Once you have that working, you'll want to use the perl installed in:

   /opt/local/bin

but I believe MacPorts will adjust your path, so just start a new Terminal shell and type:

   which perl

to be sure.

After that, its just a matter of installing the modules required by pscriptor or any scriptlet.  You just run pscriptor with any given scriptlet, and you'll see a failure sure as:

   Can't locate XML/LibXML.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.16.3...

The missing module is listed as a path "XML/LibXML.pm", and you'll mentally convert this to:

   xml-libxml

and you'll ask the ports command to install it for you by name.  Finding the name:

   port list | grep p5.16 | grep -i xml-libxml

   $ port list | grep p5.16 | grep -i xml-libxml
   p5.16-xml-libxml                   @1.840.0        perl/p5-xml-libxml
   p5.16-xml-libxml-simple        @0.930.0        perl/p5-xml-libxml-simple

and to install the module:

   sudo port install p5.16-xml-libxml

Repeat for any missing modules.

Also, be sure to uninstall ActivePerl for Mac OS X.  I don't know what their un-install procedure is, so you might want to check that out in case there is anything special required.
Logged
The opinions I express represent my own folly.

arin

  • Junior Woodchuck
  • **
  • Posts: 97

Ok MrC…here I am again!
I've installed everything following every instruction and after having unistalled ActivePerl.
No errors at all…

And when I try to run TestFile via pscriptor, after having selected some m4a audio files in MC, I get this:

Can't locate Text/CSV.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at desktop/pscriptor.pl line 19.
BEGIN failed--compilation aborted at desktop/pscriptor.pl line 19 (#1)
    (F) You said to do (or require, or use) a file that couldn't be found.
    Perl looks for the file in all the locations mentioned in @INC, unless
    the file name included the full path to the file.  Perhaps you need
    to set the PERL5LIB or PERL5OPT environment variable to say where the
    extra library is, or maybe the script needs to add the library name
    to @INC.  Or maybe you just misspelled the name of the file.  See
    "require" in perlfunc and lib.
   
Uncaught exception from user code:
   Can't locate Text/CSV.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at desktop/pscriptor.pl line 19.
   BEGIN failed--compilation aborted at desktop/pscriptor.pl line 19.



Then I tried to do this:

port list | grep p5.16 | grep -i Text-CSV


Followed by this:

sudo port install p5.16-text-csv


And I got this:

--->  Computing dependencies for p5.16-text-csv
--->  Dependencies to be installed: perl5.16 gdbm gettext expat libiconv ncurses
--->  Fetching archive for expat
--->  Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/expat
--->  Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/expat
--->  Installing expat @2.1.0_0
--->  Activating expat @2.1.0_0
--->  Cleaning expat
--->  Fetching archive for libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/libiconv
--->  Installing libiconv @1.14_0
--->  Activating libiconv @1.14_0
--->  Cleaning libiconv
--->  Fetching archive for ncurses
--->  Attempting to fetch ncurses-5.9_2.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/ncurses
--->  Attempting to fetch ncurses-5.9_2.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/ncurses
--->  Installing ncurses @5.9_2
--->  Activating ncurses @5.9_2
--->  Cleaning ncurses
--->  Fetching archive for gettext
--->  Attempting to fetch gettext-0.18.3.2_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/gettext
--->  Attempting to fetch gettext-0.18.3.2_0.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/gettext
--->  Installing gettext @0.18.3.2_0
--->  Activating gettext @0.18.3.2_0
--->  Cleaning gettext
--->  Fetching archive for gdbm
--->  Attempting to fetch gdbm-1.11_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/gdbm
--->  Attempting to fetch gdbm-1.11_0.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/gdbm
--->  Installing gdbm @1.11_0
--->  Activating gdbm @1.11_0
--->  Cleaning gdbm
--->  Fetching archive for perl5.16
--->  Attempting to fetch perl5.16-5.16.3_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/perl5.16
--->  Attempting to fetch perl5.16-5.16.3_0.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/perl5.16
--->  Installing perl5.16 @5.16.3_0
--->  Activating perl5.16 @5.16.3_0
--->  Cleaning perl5.16
--->  Fetching archive for p5.16-text-csv
--->  Attempting to fetch p5.16-text-csv-1.210.0_3.darwin_13.noarch.tbz2 from http://nue.de.packages.macports.org/macports/packages/p5.16-text-csv
--->  Attempting to fetch p5.16-text-csv-1.210.0_3.darwin_13.noarch.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/p5.16-text-csv
--->  Installing p5.16-text-csv @1.210.0_3
--->  Activating p5.16-text-csv @1.210.0_3
--->  Cleaning p5.16-text-csv
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.


Then I rerun TestFile via pscriptor and got this:

Can't locate Text/CSV.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at desktop/pscriptor.pl line 19.
BEGIN failed--compilation aborted at desktop/pscriptor.pl line 19 (#1)
    (F) You said to do (or require, or use) a file that couldn't be found.
    Perl looks for the file in all the locations mentioned in @INC, unless
    the file name included the full path to the file.  Perhaps you need
    to set the PERL5LIB or PERL5OPT environment variable to say where the
    extra library is, or maybe the script needs to add the library name
    to @INC.  Or maybe you just misspelled the name of the file.  See
    "require" in perlfunc and lib.
   
Uncaught exception from user code:
   Can't locate Text/CSV.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at desktop/pscriptor.pl line 19.
   BEGIN failed--compilation aborted at desktop/pscriptor.pl line 19.


Any new suggestions?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

The @INC path in the error message from perl shows that the OS X version of perl is being used, not the new /opt/local/bin version you installed via Mac Ports.

Try looking at the PATH environment variable:

   echo $PATH

Code: [Select]
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/MrC/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

and if /opt/local/bin is not at the front of the PATH, that's the cause.  Did you start up and use a new Terminal window (new shell) after installing the MacPorts package?  (see my above message about this).  MacPorts will add this entry:

Code: [Select]
# MacPorts Installer addition on 2013-04-06_at_09:45:09: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

to your .bash_profile.  Having the PATH set properly means you don't have to type full path names to the executables in /opt/local/bin:

   /opt/local/bin/perl pscriptor.pl ....

and instead can use:

   perl pscriptor.pl ....

Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

I recall some folks in the past have asked about extracting embedded cover art.

So I've written a scriptlet to extract embedded cover art from audio files.  It currently places the artwork in the same folder as the audio file, using the name prefix "coverart" and with the proper suffix given the file type.  The name prefix can also be user-specified.  Examples:

  coverart.png
  Folder.jpg

Most album's tracks will have the same cover art.  So I'm wondering if it is OK to leave as a limitation that a user must filter all but one track from albums.  The scriptlet would then only pull cover art for one file / per album (i.e. the files in the view), and this would be much faster to process.  There would be no harm in leaving all the files in the view, the file will just get created over and over, once for each track.

For the cases where there is unique per-track cover art in an album, would it be sufficient to prefix the given file names with the disc/track number?  Examples:

  1 coverart.jpg
  1-2 Folder.jpg

I could also use the track's Name, or really any field in the view (including your own expression field).  But I have to be careful about path length limitations.  Suggestions?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Hello MrC,

do you think you can add a script that extracts  a playlist (as m3u8) to a pre-specified folder copying the files alongside with the playlist?

Thank you
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Sure.  I'll take a look tomorrow.

Where will the playlist come from?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

From MC.

I have some playlists that I want to give to some friends of mine (together with the songs) or even take them with me at my android or USB stick, but since many of my songs have Spanish characters I can't do that through "handheld devices" in MC.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Ok, so it will work based on the selection of files.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Yes, thank you  :) Can it also work based on the selection of playlists?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Pscriptor has no access to those as a selection.  It gets it's data from the clipboard, and the selected playlist names won't be there.  Only the view's file list data is available, so that means the file list files must be selected.  However, if the view contained the Playlist column, and it's value was meaningful for grouping, then it might be used to create these virtual groups.  I'm not sure the playlist's file ordered would be retained.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

OK we can check and see how it goes. I think it will be faster to reorganize the file order in a program, than find each link in a m3u playlist that has a special character and correct it (this is what I have to do now each time I extract the playlist with the files through MC).
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

@stiv32 - I'm thinking about how i want to implement the Copy and Make M3U8 playlist feature.

I'll need to know how you'll want to deal with directories.  You can supply a Base path, and I'll have existing file paths, but I'd like to know your requirements for how to build up the final destination path.  Example:

   M:\Music\Philip Glass\Koyaanisqatsi\03 Clouds.flac

it could work such that a certain pattern should be removed from the front, replacing it with some replacement value, as in:

   M:\Music ==> Z:\Copied Files

leaving you with:

   Z:\Copied Files\Philip Glass\Koyaanisqatsi\03 Clouds.flac

And/or it could work by using only the file name, placing the files in some single specified directory:

  Z:\Some Base Directory\03 Clouds.flac

Or it could work based on some expression field you have in the view.

Thoughts?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162


Could we use for the songs; paths relative to the playlist?

In that way I could point where the playlist will be created/extracted (i.e. z:/music/) and the files can either be copied in a folder there (../songs) or they can be copied to the path ../[artist]/song.mp3.

 
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Sure, but you need to think about how you want to handle collisions.  If I copy these two files:

   M:\Music\<various artists>\A Very Special Christmas\01 I Saw Three Ships.flac
   M:\Music\Mannheim Steamroller\Christmas 1984\01 I Saw Three Ships.flac

Then we get identical files at the same location:

    Z:\Music\<playlist name>\01 I Saw Three Ships.flac

So I have to start testing:

   - Does the file exist?
      - Yes, derive a new name and repeat the process...

Since by definition your existing file paths don't have collisions, using the existing hierarchy makes the job easier.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

That means that we could copy the existing file paths and make them relative to the playlist, right?

One thing that might go wrong here is the length of those paths when we add them to the playlist folder. If we get the whole link of each track we might end up with more than 256 characters per path.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

That's the idea, but you're saying it backwards.  The new M3U8 playlist entries will either be absolute paths, or can be relative paths.  If relative, the new playlist can be located anywhere in the new path tree, so long as its entries are valid.

I've been presuming you want:

   Z:\Music\<playlist name>
   Z:\Music\<playlist name>\playlist.m3u
   Z:\Music\<playlist name>\folders\files

so the m3u8 paths will be either of:

     Z:\Music\<playlist name>\folders\files
     .\folders\files  (with or without the .\ prepended)
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Do we need the "Z:\Music" path?

I mean that if the positions of the files and playlist are relative to each other, wherever we place the folder containing them should be fine, right?

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

I should have just said <basepath> which could be an absolute or relative path to a folder.

The problem with relative paths... what will it be relative to?  If you just say "folderX", where is folderX from pscriptor's or MC's point of view?
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Ok, I have the basic script done, and have named it in your honor, for now anyway.  :)   It is called Stig32inator.

It uses the field supplied in -f as the grouping field.  This might be, for example, the Playlists column, a value from the Comment field, or whatever.  It uses an argument supplied by -a as the destination base path (where the new files will be located.  e.g. -a 'path=Z:').

For each grouping:
   - it creates an m3u8 playlist containing a list of the files in that grouping  
   - it copies the original file to a location specified by the -a supplied base path

To make sure it meets your Unicode needs, I've verified the name in the playlist and file copied using the filename:

      Prélude à l´après-midi d´un faune.mp3

Now, we just have to decide how you want to handle any sub directories for tracks.  Right now, if you had two playlists names as the groupings, the scriptlet would create:

   Z:\playlist1.m3u8
   Z:\file1_in_playlist1
   Z:\file2_in_playlist1
   Z:\playlist2.m3u8
   Z:\file1_in_playlist2
   Z:\file2_in_playlist2

Maybe you want them like this, however:

   Z:\playlist1
   Z:\playlist1\playlist1.m3u8
   Z:\playlist1\file1_in_playlist1
   Z:\playlist1\file2_in_playlist1
   Z:\playlist2
   Z:\playlist2\playlist2.m3u8
   Z:\playlist2\file1_in_playlist2
   Z:\playlist2\file2_in_playlist2

or even (note the generic playlist name "playlist.m3u8"):

   Z:\playlist1
   Z:\playlist1\playlist.m3u8
   Z:\playlist1\file1_in_playlist1
   Z:\playlist1\file2_in_playlist1
   Z:\playlist2
   Z:\playlist2\playlist.m3u8
   Z:\playlist2\file1_in_playlist2
   Z:\playlist2\file2_in_playlist2

 Also, how do you want to handle existing files?  Overwrite them?  Abort the copy for that file?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Thank you very much for the honor MrC  :D


The second and third options seem to be more robust for any future needs that anyone might have. Could it start with no numbering? For example

   Z:\playlist
   Z:\playlist\playlist.m3u8
   Z:\playlist\file1_in_playlist
   Z:\playlist\file2_in_playlist
   Z:\playlist1
   Z:\playlist1\playlist.m3u8
   Z:\playlist1\file1_in_playlist1
   Z:\playlist1\file2_in_playlist1

Also, since we place the files in different folders to we need renaming them into file_in_playlist(n) ?

For existing files I think the safest option should be to overwrite them, or even better have the option beforehand to overwrite them or add _(n) at the end of the file.

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

The file names and playlist names, including the numbers, were just two example names I picked to help you see what was going on.   For example, "file2_in_playlist2" is really some file name like:

   09 Love Hammer.mp3

or if directories are to be used:

   Big Willie\His Big Monster\09 Love Hammer.mp3

The playlist names don't require any numbers; they will come from your own MC field, so however you want to name them is up to you.

I'm just tossing ideas out - you tell me what *you* need.
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Here's the way to think about it.  You have some existing file paths, that look like:

   M:\A\B\C\D\E\foo.mp3

and you want to create a copy with a playlist to some other location X (this is the base path you give to the scriptlet).  What should the final path look like?  It will be something like:

   X\....

What should the .... look like?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

I am sorry that it took me a while to completely understand what you were saying.

I think the third option would be the functional for me  :)

In this case since there might be some duplicate "Filename (name)"s in the same playlist and since the purpose of this kind of playlists is to take the songs with you, I guess the best option would be if the file comes from the same path it shouldn't be copied but if it comes from a different path the it should be copied like that  /file_(n)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Got it.

Your comments on dups in playlists.  This might be tricky.  Currently, once the file is copied, it exists as some named file.  Later, I have no idea from whence it came.  I can probably create a reverse relationship mapping the new file name back to the original path.

I think what I'm going to do is allow you to use some column in your view, which might be an expression column or field, which indicates the hierarchy to be used beneath X.  If the field is not there, or is empty, then there will be no subfolders hierarchy.  If you do have one, perhaps it is defined like:

   [Artist]\[Album]

then they will be used, creating:

   X\[Artist]\[Album]

Further, I could see allowing you to define the Filename part too and it could include automatically numbering the tracks using some special token like [seq]:

   X\[Artist]\[Album]\[seq] [Filename (name)]

This would allow file names like:

   01 Hello.mp3
   02 Goodbye.mp3
   03 For Now.mp3

or even the degenerate:

   01.mp3
   02.mp3
   03.mp3

This would give you complete control over the naming and location.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

I like very much the option with the folder hierarchy.

The numbering in front of the file can be used maybe to protect the order of the songs in the playlists!  ;)

The script works on one file each time right? So, we can have the first file renamed to 01..., the second to 02... etc. In this way duplicates (only by "Filename (name)") won't trouble us.

The only problem could be the real duplicate entries in the playlist, but this isn't really a problem because the storage space is not really a problem nowadays, and we are not talking about the database where we don't want any duplicates but we are talking about a "playlist to go" where this is not a problem.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Yes, that's correct.  That's exactly why I suggested the [seq] number token, to allow you to number as you want.

The script works in three stages:

  1. pre-processing (which has access to everything but can't write back tags)
  2. per-file processing (which gets only a single files's data and can write back one or more values)
  3. post-processing (which only has access to its -a argument string, and can't write back tags)

The file numbering is trivial - all your files names and tags are held in an array, and the index is readily available.

I will track duplicate entries in the original playlist, and if there is no [seq] in use, then their new playlist entries will reference the single version of the copied file whatever its name may be.  I won't copy/store the same file twice in this case.  If you do use [seq] to sequence the files, then I suppose a copy will be created (I don't think I want to get into using symlinks or shortcuts because I don't know what the remote system will do with those).
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

If you have any beta version MrC I would be glad to test it :)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

I'm working on it now.  I'm just about to make the playlist entries relative instead of absolute (you want this option, right)?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Yes, of course  :)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Question.  Currently I'm allowing you to create multiple playlist groups:

   group1
       playlist.m3u8
       files
   group2
       playlist.m3u8
       files

I presume you want the sequence number restarted for each group, so files go from 1 to n inside each grouping.  Is this correct?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

That's correct!

Do I have to process each group at once? That is, choose the playlist files and run the script once for each group?

Even if this is the case I won't have a problem cause each playlist has about 160 to 170 files in. But in such case shouldn't we consider the needs of others as well?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Sorry, I had some social engagements today.

You won't have to do one run / group.  All you need is some field that indicates the name you want to use for a playlist.  So if some group as a tag Playlist A and the others have Playlist B, then the script will split the files into two folders, each with their own playlist.m3u8 and their respective files in the order shown in the view.

I have everything done except dealing with overwriting files and avoiding duplicates.  Do you want to try out what I have?
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Of course! Do you want to upload it here? I believe you also have my email, so however you prefer is fine :)
Logged

stiv32

  • World Citizen
  • ***
  • Posts: 162

Please, also send me a sample command so that we avoid some mistakes there ;)

Should I add some duplicates in the playlist?

Do we need to test against other things as well, or just try it to some of my playlists and see how it goes?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Edit: The attached test version of pscriptor has been removed as this scriptlet is now included in the pscriptor release.  The scriptlet is now called CopyWithM3U8.

Here's a zip file that contains pscriptor.pl, the config file, and Scriptlets/Stiv32inator.pm.  Unzip and place them in the correct location.

You may need to add a new perl module.  In the command shell, use:

   ppm install Win32-Unicode

If you get other missing modules, do the same thing with the module name shown in the error message about missing modules.  Change the :: into a - character.

Here's a sample command line, and I'll explain the options, ignoring those you know about:

   perl pscriptor.pl -c pscriptor-config.txt -E Stiv32inator -f "Playlist" -a "base:M:\Copied Music  fname:<seq>-<fname>"

The -f option used with Stiv32inator indicates the playlist name.  The value in this field will be used to create the playlist groupings.  You can see in the screen shot my values Playlist A and Playlist B, and the folders created in the two sample output runs.  If the value in view for the -f field is empty, no playlist folder is created and files are placed in the base path.

The -a option supplies specific options to Stiv32inator.  There are currently four available options you can use to control how the files and folders are created.  The options take the form of opt:value, that is, the option name followed by a ':' character, followed by the value.  See below for more examples.  The three options are:

   - base  - defines the destination base path; everything gets placed either here or in subfolders.  This is required.

   - fname - defines how the file's name will be created.  It is optional and if omitted, the source file's name will be used.  If you use the fname option, there are some "tokens" that can be used to define how to create the fname.  Two tokens are pre-defined: <seq> and <fname>, but your track columns can be used too.  The token <seq> is the per/playlist sequence number and is optional.  It also accepts a digit-width specifier to indicate how many digits you want (for padding).  For example, use <seq,3> for 3 digits.  The simple value <seq> would output a 1 digit sequence.  The <fname> token is the file's name.  It is optional also.   You can add extra characters between tokens and they will be output as part of the filename.  To use values from your file list columns, use the token <[column]> where column is the name of your column.

   - folderfield - this is the name of an expression column in the view. The value in the view should be an expression that creates a valid path fragment, defining where files will go.  For example, if you want your playlist files to go into an artist\album hierarchy, use the expression: [Artist]\[Album].  Then, files will go into: base\folderfield\name.  Certain illegal file system characters are transformed into underbar.

   - delete - this option when set to 'yes' will delete pre-existing destination files.  Otherwise, a new file with the same name as an existing file will have its named appended with "(n)", where n is the next available unused index in the directory.

Here are a few examples from, from the -f option onwards:

    -f "Playlists" -a "base:M:\Music\Copied"
    -f "Playlists" -a "base:M:\Music\Copied  fname:<seq> delete:yes"
    -f "Playlists" -a "base:M:\Music\Copied  fname:<seq>"
    -f "Playlists" -a "base:M:\Music\Copied  fname:<seq,5>"
    -f "Playlists" -a "base:M:\Music\Copied  fname:<seq> <fname>"
    -f "Playlists" -a "base:M:\Music\Copied  fname:<seq,2>--<fname>"
    -f "Playlists" -a "base:M:\Music\Copied  fname:<seq,4> <[name]>-<[bitrate]>"
    -f "Playlists" -a "base:M:\Music\Copied  folderfield:MyFolderExpr  fname:<seq,2>--<fname>"

As usual, add the -v option on the command line if you want to see verbose output about file and folder creation, file copies, etc.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

When do we use Clean() ?

I get this


perl pscriptor.pl -v -c pscriptor-config.txt -E Stiv32inator -f "
M3U8_Playlists" -a "base:C:\1  forlerfield:music name:<seq,3>-<name>"
Uncaught exception from user code:
        Stiv32inator: Destination base path is not a clean base path - it contai
ns filesystem illegal characters.
        Stopped at Scriptlets/Stiv32inator.pm line 61.
        Stiv32inator::do_preprocessing("base:C:\\1  forlerfield:music name:<seq,
3>-<name>", ARRAY(0x2c4a710), ARRAY(0x2ffd778)) called at pscriptor.pl line 148

I just copy pasted the Sitv32inator script. Should I get also pscriptor.pl and config file?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

.... M3U8_Playlists" -a "base:C:\1  forlerfield:music name:<seq,3>-<name>"

The problem is that you've misspelled folderfield, so that option isn't recognized, therefore it looks like your base path is:

   C:\1  forlerfield:music

and : is illegal.  You don't need Clean() - I do that for you.

Update all three files - that's why I included them.  You can ignore the config file for now.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

At the first playlist I checked everything went fine. All 168 files were copied and the order of the songs in playlist was kept fine since I could order the tracks by Filename.

Instead of

name:<seq>-<name>

can I change it to something like

name:<seq>-<Filename (name)> ?
[/s]

What I wanted to say is

In addition to adding the Seq to "Filename (name)" can we add it also to "Name" of the track?

I ask this because when we load the playlist at some players we can see just the Name of the track and not the Filename, so we can't order by Filename.
Thank you very much MrC

ps. I will do some more testing and write here if I have any problems

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Great.

The <name> token is Filename (name).
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Sorry I corrected my question  :-[



Instead of

name:<seq>-<name>

can I change it to something like

name:<seq>-<Filename (name)> ?
[/s]

What I wanted to say is

In addition to adding the Seq to "Filename (name)" can we add it also to "Name" of the track?

I ask this because when we load the playlist at some players we can see just the Name of the track and not the Filename, so we can't sort by Filename.
Thank you very much MrC


Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

I'll take care of this tomorrow.
Logged
The opinions I express represent my own folly.

stiv32

  • World Citizen
  • ***
  • Posts: 162

Thanks  :D
Logged
Pages: 1 2 [3] 4 5 6   Go Up