INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: vb script to export playlist?  (Read 5743 times)

alspoll

  • World Citizen
  • ***
  • Posts: 118
vb script to export playlist?
« on: August 24, 2008, 04:25:06 pm »

Hello,

Does anyone have a visual basic script that will export a specific playlist into a text file, specifying only visible fields? I have been looking at the wiki and the site all day and have not across something that will perform this task. I came across one script that will only give file name, but I do not see a way to select a specific playlist, output type or what fields are included.

I appreciate any help someone can provide.

TIA

AL



Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: vb script to export playlist?
« Reply #1 on: August 24, 2008, 05:30:09 pm »

may i ask why you would want that? when doing ctrl & a and then  ctrl & c in the playlist and ctrl & v in notepad, i get what you want. so my first thought was that a script would be a bit overdone.

 :)
gab
Logged

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #2 on: August 24, 2008, 05:39:04 pm »

what i am trying to do is automate the loading of this information into excel and then have excel format this information. it is an experiment to get some data into Mainlobby and musiclobby. i figure i can schedule this to run during the night so not to interrupt the computer and have all processing done by the morning. i realize it is easy to do as you suggest but i want to have a script that will complete all the necessary steps, this being the first one.

TIA

Al 
Logged

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #3 on: August 24, 2008, 09:31:47 pm »

nobody?

i know i am not familiar with coding, but i figured one of the experts could help me out  ;)
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #4 on: August 25, 2008, 03:55:58 am »

Sure it should be possible by creating a VB.NET Script.
I take it you are refering to this script
http://yabb.jriver.com/interact/index.php?topic=33020.msg316126#msg316126

The script above this gives an example of using a specific playlist
http://yabb.jriver.com/interact/index.php?topic=33020.msg302765#msg302765

These are both written using C# scripts however it is possible to rewrite them in VB.NET.

There should be no problems getting specific fields out as well.

However I don't think playlists themselves actually specify what fields are visible, so i'd imagine you'd have to hard code the fields.
Is this the sort of thing you are looking for?
If so I'll endevour to help you create the script over the next week or so..
My girlfriends just dumped me so not in the mood at the moment. ?

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: vb script to export playlist?
« Reply #5 on: August 25, 2008, 04:10:21 am »

My girlfriends just dumped me so not in the mood at the moment. ?

im sorry hear that.

 :(
gab
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #6 on: August 25, 2008, 05:15:06 am »

im sorry hear that.

 :(
gab


Thanks, I'll live just in a grumpy mood.  More fish in the sea so they say! (Other reports say the sea's overfished).

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #7 on: August 25, 2008, 06:56:36 am »

Sorry to hear... but I appreciate any help provided.

TIA

AL
Logged

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #8 on: August 25, 2008, 07:02:47 am »

Sure it should be possible by creating a VB.NET Script.
I take it you are refering to this script
http://yabb.jriver.com/interact/index.php?topic=33020.msg316126#msg316126

The script above this gives an example of using a specific playlist
http://yabb.jriver.com/interact/index.php?topic=33020.msg302765#msg302765

These are both written using C# scripts however it is possible to rewrite them in VB.NET.

There should be no problems getting specific fields out as well.

However I don't think playlists themselves actually specify what fields are visible, so i'd imagine you'd have to hard code the fields.
Is this the sort of thing you are looking for?
If so I'll endevour to help you create the script over the next week or so..
My girlfriends just dumped me so not in the mood at the moment. ?


Yes I was referring to your script as you indicated above. Instead of inerfacing with another program i just want to output the info to a delimited file.

TIA

AL
Logged

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #9 on: August 29, 2008, 09:59:41 am »

Mr ChriZ,

I tried to paste one of the scripts into Visual Basic 2008 Express Edition and I received numerous errors. The script I used was:

using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {       
       //Get the current playing now playlist
        MediaCenter.IMJCurPlaylistAutomation  myPlaylist = mediaCenterInterface.GetCurPlaylist ( );


        for(int counter = 0; counter < myPlaylist.GetNumberFiles(); ++counter)
        {
            //Get Individual File From Playlist
            MediaCenter.IMJFileAutomation mediaFile = myPlaylist.GetFile(counter);

            //Get File Name
            string fileName = mediaFile.GetAvailableFilename();

            //Do your business with File...   
            Console.WriteLine(fileName);
        } 

    }
}

Is there anything special I need to select in Visual Basic 2008 Express Edition that will allow me to run the script.

TIA

AL
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #10 on: August 29, 2008, 02:31:54 pm »

Hi Al,

VB Express 2008 isn't necassery.
You want the scripting plugin for Media Center which is available here:
http://accessories.musicex.com/mediacenter/mc_data/plugins/833.mjp

You can then paste the script in this this, and you might have better luck!
I will provide more help soon..

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #11 on: August 29, 2008, 04:22:52 pm »

Hi Al,

VB Express 2008 isn't necassery.
You want the scripting plugin for Media Center which is available here:
http://accessories.musicex.com/mediacenter/mc_data/plugins/833.mjp

You can then paste the script in this this, and you might have better luck!
I will provide more help soon..

Thank you Mr ChriZ. I did not know that there was a scripting plugin.

Also, I violated the first rule of script writing: Use the correct editor for the language you are using.

So, now your above script works. Is there a way to run these script outside of mediacenter?

TIA

AL
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #12 on: August 29, 2008, 04:38:56 pm »

There is, the scripts are actually run by a command line tool which can be run completely seperatley.
Attached to this post is a zip file with the command line tool and an example script, and batch file to run it.
The command line tool can also be found under the script plugins directory, possibly the compilation config file is different however,
I don't remember.

The zip file one definitley works.
Currently MC must be open prior to running the script.  This didn't used to be the case so not sure what's happening there.

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #13 on: August 29, 2008, 05:50:02 pm »

Mr ChriZ

Now I need to read up on .net... What version of visual basic should I be referencing, 2005, 2008, ...?

I will definitely get use of this plugin, but how can I also write/test scripts using visual studio?

TIA

AL
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #14 on: August 30, 2008, 07:00:39 am »

The scripting plugin currently uses .NET version 2.0 as does Visual Studio 2005.
.NET 3 maybe supported in the future.

Technically you could open the scripts in Visual Studio already, and with a bit of prodding it might give you the intellisense functionallity which is very useful.  I have intended to try and add it to the plugin myself but I'm kind of waiting for someone to produce some drop in editor which I can use as it's too large a project for me to undertake in spare time.

I don't know that you could easilly get VS to run the scripts.  Your best bet might be to open the script in Visual Studio, and then run them directly from the command line as you are making changes.

The plugin is supposed to detect external changes to the script file, but this is a bit flimsy if I remember correctly.

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #15 on: September 01, 2008, 07:53:22 pm »

I don't know that you could easily get VS to run the scripts.  Your best bet might be to open the script in Visual Studio, and then run them directly from the command line as you are making changes.

Mr ChriZ,
Not sure i understand. If the script is written in Vb.net, why wouldn't VS be able to run it?
Sorry if this is a dumb question.

TIA,

AL
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #16 on: September 02, 2008, 03:19:03 am »

You could do it however you'd have to set up a project to call the script using the Media Center out of proc references.  The script running executable does this for you.

Effectively you'd be removing the scripting plugin from the equation, and just creating an out of proc project.  There's some pages on how to do this around here if you do a search.

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #17 on: September 06, 2008, 07:55:23 am »

How are you getting on with this Al?
Let me know if you need more help.

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #18 on: September 06, 2008, 03:03:01 pm »

Mr ChriZ

Thank... I have been traveling for work the last week and have not had chance to work on this. I am off next week and plan on spending some time getting this to work.

...and I am sure there will be some questions.  ;)

AL
Logged

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #19 on: September 07, 2008, 12:38:50 pm »

slowly making no progress...  :-\

i tried the below code;
Code: [Select]
using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {       
       //Get the current playing now playlist
        MediaCenter.IMJCurPlaylistAutomation  myPlaylist = mediaCenterInterface.GetCurPlaylist ( );


        for(int counter = 0; counter < myPlaylist.GetNumberFiles(); ++counter)
        {
            //Get Individual File From Playlist
            MediaCenter.IMJFileAutomation mediaFile = myPlaylist.GetFile(counter);
   
            //Get File Name
            string fileName = mediaFile.GetAvailableFilename();
                 MediaCenter.IMJPlaylistsAutomation  Playlists = mediaCenterInterface.GetPlaylists( );
;               
           
            //Do your business with File...   
            Console.WriteLine(fileName);
             
            Console.WriteLine(Playlists);
                 
        }

    }
}

and received the following output:
Code: [Select]
Compiling Script...
Script Compiled Successfully!
Running Script...
Z:\MUSIC\2 Skinnee J's\Sexy Karate\2 Skinnee J's - Sexy Karate - 01 - Get In The Van.ape
System.__ComObject
Script Completed Successfully

what i am trying to do is determine what playlists the file belongs to besides the current playing now. i think my biggest issue is with syntax and not the flow. right now there is only 1 file in playing now. I am doing a test to get this to work before adding additional code.

As an aside, i ran the test script which lists all files in playing now and it takes around 10 minutes  to read each file. When I use the export playlist menu, it takes just a few seconds. I assume jriver used optimized code to iterate through the files. in the end it might just be easier to manually export the file as was suggested, but then i do not learn how to code... such decisions.

TIA

AL
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #20 on: September 08, 2008, 06:35:02 am »

10 Minutes? Eh?

The scripts are as quick as standard .NET, and the MC interface is very quick too...
that doesn't make sense.

i just ran that script you've provided and it instantly outputted
:
Compiling Script...
Script Compiled Successfully!
Running Script...
E:\Track01.cda
System.__ComObject
E:\Track02.cda
System.__ComObject
E:\Track03.cda
System.__ComObject
E:\Track04.cda
System.__ComObject
E:\Track05.cda
System.__ComObject
E:\Track06.cda
System.__ComObject
E:\Track07.cda
System.__ComObject
E:\Track08.cda
System.__ComObject
E:\Track09.cda
System.__ComObject
E:\Track10.cda
System.__ComObject
Script Completed Successfully

Less than a second from compilation to running.

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #21 on: September 08, 2008, 07:37:54 am »

I should have provided more details...

There are are 63,000 tracks in playing now, not just the one indicated in the output above and this is an old computer. I just provided the times to give some relativity.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: vb script to export playlist?
« Reply #22 on: September 08, 2008, 11:10:39 am »

The Console output is very slow.
You can prove this by creating a script like the following
using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {       
       //Get the current playing now playlist
        MediaCenter.IMJCurPlaylistAutomation  myPlaylist = mediaCenterInterface.GetCurPlaylist ( );


        for(int counter = 0; counter < 63000; ++counter)
        {
           
        }

    }
}


It will complete almost instantly.
So what you really want to do is output directly to a file.
I'll write something up later that will show you how to do this.

alspoll

  • World Citizen
  • ***
  • Posts: 118
Re: vb script to export playlist?
« Reply #23 on: September 12, 2008, 01:10:50 pm »

The Console output is very slow.
You can prove this by creating a script like the following
using System;
using System.Windows.Forms;
//css_reference MediaCenter.dll;

class Script : MarshalByRefObject
{
    public void Init(MediaCenter.MCAutomation mediaCenterInterface)
    {       
       //Get the current playing now playlist
        MediaCenter.IMJCurPlaylistAutomation  myPlaylist = mediaCenterInterface.GetCurPlaylist ( );


        for(int counter = 0; counter < 63000; ++counter)
        {
           
        }

    }
}


It will complete almost instantly.
So what you really want to do is output directly to a file.
I'll write something up later that will show you how to do this.


Mr ChriZ,

Have you had a chance to write up a sample?  I am curious to see the correct syntax to use.

TIA,

AL
Logged
Pages: [1]   Go Up