INTERACT FORUM

Please login or register.

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

Author Topic: Scripting Plugin (Abit like Visual Basic for Applications, only .NET for MC!)  (Read 65462 times)

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Description
This plugin allows you full access to the Media Center Programming Interface
using Scripts written in either C# or VB.NET.
These can be compiled and run on the fly with Media Center open!
The programming interface is exactly the same one as used by all the interface
plugins out there.
The Script's have full access to the .NET framework.  Theres next to nothing you can't do.

Screenshot
This image here shows what the plugin looks like when running.

Pre-requesits
Make sure you have the latest version of the .NET Framework 2.0.  This is installed as standard in Windows Vista, 7, 8 etc but may need installing for Windows XP.

.NET 2.0 must be installed.   .NET 3.0/.NET 4.0 on their own will not suffice.

Where do I get it?
Now available here for instant download
This is a beta version

Click Here Go to Download Site

Installation
Close Media Center before Installation.
Go through the setup program.
Open Media Center,
Go to Services and Plugins in the tree.
Scripting plugin should be there.

Acknowledgments
This plugin would not be possible without the exceptional genius of Oleg Shilo
who wrote the C# Scripting engine
http://www.codeproject.com/csharp/cs-script_for_CP.asp
http://www.members.optusnet.com.au/~olegshilo
or the use of #Develops Editor
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

Current Build Status as of 23/06/2007
>Release Candidate 1 Version 0.6.5.0
- Minor Release Fixing Kill Bug

[0.6.0.0]
* Scripts are now started using a helper command line tool ScriptRunner.exe
* Scripts start in their own Application Domain, allowing handling of events
and threads etc.
* Scripts can be started without the script plugin
* Textbox output is now performed using standard output

Current Plugin Supports
>VB Scripts New!
>Template Scripts to start you off
>Real Time Editing of scripts (You type, it saves)
>Undo/Redo by Ctrl-Z, Ctrl-Y
>Creating of new scripts
>Renaming Scripts (You type it renames, You type the wrong thing it breaks)
>Exploring Script Directory
>Output for Compile Errors
>Compilation and running of scripts
>Starting One Script From Another!
>Script running on a new thread
>LED Indication of Thread Running
>Ability to kill that thread
>Detection of file changes
>Ability to output strings to the output textbox (Via TextBox reference)
>Syntax Highlighting
>Line Numbers
>#Develops Editor

There  are some obvious desirables in the future
such as

>Java Script? (If People want it)
>Remote starting of a script
>Script Backup System
>Optional non real-time editing interface
>Running Scripts on Startup of MC
>Refresh to find new scripts
>Modifying of Templates (You can edit these in another editor if you like, they are under The template in the MC Plugin Directory\Script Plugin)
>Conversion of Scripts to .EXE's (Scripting engine can do this to!)
>Intellisense?  

>Your Idea here

What will the next build center on?
Unknown

Known Bugs
Kill Script Not Available When it should be...

Usage notes...
>Don't change the init method declaration else my plugin won't be able to find it!
>Theoretically you can create another class in the same script file and then create
an instance of that class from init
>Source Code will be made public as soon as I have time to tidy it up a bit, and make it worth reading!
>MediaCenter Interface is described here http://www.jrmediacenter.com/DevZone/MJAutomation.html
>If you really want the source code in it's current form just ask!

Sample Scripts
Can be found here
Feel free to add to them!

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

now that nice! i earn part of my living programming databases, but never understood this net stuff. i do have some ideas for plugins.. this could be just what i need to get me started.

thanks
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

maybe i ask something very stupid, and in the wrong thread (in which case i happely delete it). i changed some things in the template trying to understand how this mc automation works. for a test i wanted to make a messagebox telling me how much songs there are in playing now.
following the logic from the template i expected that this would work (i disabled the messagebox).

Imports System
Imports System.Windows.Forms
' //css_reference System.dll;
' //css_reference System.Windows.Forms.dll;
' //css_reference MediaCenter.dll;
Module Script   
    Sub Init( mediaCenterInterface as MediaCenter.MCAutomation, outputTextBox as Textbox)
              dim aantal as MediaCenter.IMJCurPlaylistAutomation

              aantal=mediaCenterInterface.GetNumberFiles()

              ' MessageBox.Show(aantal)

    End Sub       
End Module

but i get a long failure message. the important part is, i guess:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMemberException: Public member 'GetNumberFiles' on type 'MCAutomationClass' not found.

if its a failure in my head, please tell me so.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Hi Gappie.
I've been away for the bank holiday weekend so excuse the slow reply.
No questions are stupid.  The SDK documentation although coming
along is by no means simple to read.

What I think the problem is, is that the SDK doesn't allow you to
directly access the files without first getting them from a playlist.

There are examples I believe in the sample scripts which allow
show the handling of getting a playlist.   I'm not in front of a dev machine
at the moment, so can't test anything out for you.

Ideally the script plugin will eventually add IntelliSense, which
will make it much easier to use.  I will try to focus on that next time I come
 back to the plugin.  It is however a more formiddable project than anything
I've done recently, since I need to delve much further into the workings of #Develop.

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

no hurry, hope you had a nice holyday.
so i still dont understand something in the logic. good to know. and your answer gave a nice hint. im working on it.

thanks
gab


EDIT: just found. thanks. i did look in the plugin section before, but refused to read the C# examples. ::) its in there  ;) and now i think i really get.
for those interested, this works:

Imports System
Imports System.Windows.Forms
' //css_reference System.dll;
' //css_reference System.Windows.Forms.dll;
' //css_reference MediaCenter.dll;
Module Script   
Sub Init( mediaCenterInterface as MediaCenter.MCAutomation, outputTextBox as Textbox)
              dim lijst as MediaCenter.IMJCurPlaylistAutomation
              dim aantal as integer
              lijst=mediaCenterInterface.GetCurPlaylist ( ) 
              aantal=lijst.GetNumberFiles()
              MessageBox.Show(aantal)
    End Sub       
End Module
Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

can anyone please explain to me how to handle MC events with the scripting plugin?
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

I'll try and put up an example later.
However the plugin has a flaw in that once
a script is setup with an event, I'm not sure it can be terminated.

Out of curiosity, what are you trying to do?

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

ChriZ,
what I was thinking to write is kind of a workaround for not having math operation in calculated data fields: I want to have two different rating (manually filled) fields plus a calculated field showing the avarage between the two rating fields.

the idea is that when a Field(Rating1).OnChange or Field(Rating2).OnChange event is fired the code will update the AvarageRating field (writing the code calculated value in to it)

anyway, even if it's not possible to do it or I'll never be able to write it (the latter is more likely 8) ), i'd like to play with your plugin and events

ps the syntax i used is obviously fake, just to explain what i mean
Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

ChriZ,
thanks a lot!
it's not stopping MC at all, but I get too many notifications.
it seems to me that almost each event is fired at least twice. but if I remember correctly I get the same behavior using the "real" vb.net to handle MC events

thanks again. great work!


EDIT- I forgot to ask you: how do I stop (or at least kill) the script?

EDIT2 - just tried tagging a file: both changing the value of a field and saving the change to the file don't appear to trigger any event... if it is so, no way to write the script I wanted to create I guess
Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518


on the "too many notifications" subject.

naturally, to see what events are triggered, I've modified your message box line to:
MessageBox.Show("Test: " + bstrParam1 + " :: " + bstrParam2)


Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Correct, filtering the events down, is shown on the Wiki somewhere I believe,
the demonstration was just to show how you register interest in the events.

Unfortunatley at present once you've registered with an event, killing
the script gets more difficult, and the current plugin does not handle this at present.
I'll focus on resolving this in the next build.

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Scripting Plugin New build!
« Reply #12 on: May 14, 2007, 05:58:44 pm »

OK this has taken me a while but heres a new release of the .NET script Plugin.

Scripts are now run using ScriptRunner.exe
Scripts can be run on there own without the need for the plugin,
theoretically meaning you can schedule scripts to run or whatever.

Instead of a direct reference to the textbox, you now can output text
using System.Console.WriteLine();

It's a fairly small thing on the outside, but this took some doing!  :)
It may still need a bit of polishing.  After which I think I'll consider this plugin
released, as it's been going for almost a year and a half now!

Be warned scripts now need to inherit MarshalByRefObj,
update older scripts to match the template scripts.

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72436
  • Where did I put my teeth?

Thanks, Chriz!
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Minor Release, resolves small issue where buttons got
mixed up meaning script couldn't be killed

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518


how can I use vb commands inside the scripting plugin?

I'm trying to use some string commands, but when I try this:

  if left("cane",3) = "can" then MessageBox.Show("gotcha!")

all I get is:

 error BC30451: Name 'left' is not declared.


thanks
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

It's VB.NET rather than VB, so there's a fair number
of syntactical changes.

Left and Right have been dropped by the look of it,
instead you'll have to use Substring(startPos, numberOfCharacters)
so...
if "cane".substring(0,3) = "can" then MessageBox.Show("gotcha!")

should work.
http://www.ondotnet.com/pub/a/dotnet/2001/07/30/vb7.html?page=2

It's kind of difficult without Intellisense to automatically show
you what's happening.  Unfortunatley this isn't easy to implement,
so it's going to be a while!

Feel free to ask as many questions as you need.

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

thanks chriz!
it works now

(actually I suspected that vb.net, and plain vb could use a different syntax, but the first result for "vb.net string functions" in google is this misleading link: http://msconline.maconstate.edu/tutorials/VBNET/VBNET01/vbnet01-06.aspx, reading which I assumed wrongly that the syntax in vb and vb.net was the same)
Logged

neFAST

  • Galactic Citizen
  • ****
  • Posts: 372
  • \o/

Where do I get it?
Now available here for instant download
This is a beta version

Click Here Go to Download Site
I have a 404 here! Can you re-up it please?
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

I'm away from home this week.
Will do when I get back.

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

Mr ChriZ,
can you please help me?


Running the following code:
Code: [Select]
   
public sub Copier ( MJFile As Object)  ' <--- LINE 37
     Dim MJNewFile as MediaCenter.IMJFileAutomation
     Dim MJFiles as MediaCenter.IMJFilesAutomation       
     Dim DestFName as string, SourceFName as string
     Dim directoryName as string
      SourceFName = MJFile.Filename()
      directoryName = Path.GetDirectoryName(SourceFName)
      DestFName = directoryName & "\" & GetNewName(SourceFName)
      If System.IO.File.Exists(SourceFName) = True Then
        If System.IO.File.Exists(DestFName) = False then
             System.IO.File.Copy(SourceFName, DestFName)
             System.Console.WriteLine("File Copied")
        end if
        If System.IO.File.Exists(DestFName) = True then  MJNewFile = MJFiles.ImportFile(DestFName) ' <--- LINE 56
      End If
    end sub


I get this:
Code: [Select]
Compiling Script...
Script Compiled Successfully!
Running Script...

Failure Running Script :-
Exception has been thrown by the target of an invocation.

 The Failure Occured
 In Class Object mscorlib
 when calling Method System.Object _InvokeMethodFast(System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeTypeHandle)
 
 The following Inner Exception was causedSystem.NullReferenceException: Variabile oggetto o variabile del blocco With non impostata.
   at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
   at Script.Copier(Object MJFile) in C:\Program Files\J River\Media Center 12\Plugins\Script Plugin\Scripts\New Script 2.vb:line 56
   at Script.Init(MCAutomation mediaCenterInterface) in C:\Program Files\J River\Media Center 12\Plugins\Script Plugin\Scripts\New Script 2.vb:line 37
 
 Everything that follows forms the stack Trace:


Server stack trace:
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at CSScriptLibrary.AsmBrowser.Invoke(Object obj, String methodName, Object[] list)
   at CSScriptLibrary.AsmRemoteBrowser.Invoke(Object obj, String methodName, Object[] list)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at CSScriptLibrary.IAsmBrowser.Invoke(Object obj, String methodName, Object[] list)
   at CSScriptLibrary.AsmHelper.InvokeInst(Object obj, String methodName, Object[] list)
   at ScriptRunner.ScriptRunner.Main(String[] args)


Why?!

Thanks
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

OK I've taken a quick look...
Your line 56:
 MJNewFile = MJFiles.ImportFile(DestFName)

I believe you're trying to import the new file that's been copied back into the library.
I don't think however that MJFiles is connected to the Media Center interface,
so it has no way of talking to Media Center.

I can't find the wiki entry for how ImportFile is supposed to work.
Post a link if you find one.

That might be enough to get you going again, if not post a link
and I'll see if I can work out how to connect that interface up.
I've not imported any files in before.

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

I believe you're trying to import the new file that's been copied back into the library.

yep,
if find one, i'll post the solution.
thanks anyway
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

As I said if you can't get it to work, just give me another yell,
and I'll look into it more.

bil1010105

  • World Citizen
  • ***
  • Posts: 142

Hi, I'm getting a 404 error when I try and download this plugin.  :(
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Try again..
I've reuploaded it.

neFAST

  • Galactic Citizen
  • ****
  • Posts: 372
  • \o/

Little OT question to Mr Chriz: Have you ever compiled a *display* plugin? Is it far from an interface one?
Thx in advance.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Not yet I'm afraid, I've had an idea recently, but
have so little time to play with these things anymore.

Might have a go at some point over the xmas break.
Family tends to drive me to things like that  ;)

leezer3

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1588

Just noticed this one, thanks  :)
Is there any way to call a Perl script (In a roundabout way if necessary) using this plugin?
I'm much more comfortable with Perl than .Net, and I've got a couple of scripts that would be handy if I could call them from MC.

Link is also broken, would appreciate another.

-Leezer-
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Just noticed this one, thanks  :)
Is there any way to call a Perl script (In a roundabout way if necessary) using this plugin?
I'm much more comfortable with Perl than .Net, and I've got a couple of scripts that would be handy if I could call them from MC.

-Leezer-

I'm afraid not.
C# uses C syntax, but with objects etc, is much simpler.
There's also growing library of sample scripts around, so it might not be to difficult
for you to convert them.

I'll also lend a hand if you get stuck at all!


leezer3

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1588

No real probs, a little more work really :)

Would appreciate a re-upload somewhere though.

Cheers

-Leezer-
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

http://www.wikifortio.com/665832/setup.exe

Try that one.  I've moved house recently, which has allowed me to seperate work and play a
bit, so hopeful that I may get some time to do an update of this sometime soon.

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

Can anyone explain to me why this code:

Code: [Select]
Dim NewLastPlayed as date
Dim d1 As DateTime = DateTime.Now
[more code]
NewLastPlayed = d1
MJFile.Set("Last Played", NewLastPlayed)

give me "01/01/1970 1.00" when the Last Played field is displayed in MC???

My PC system date and time is correct so I don't understand.
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

Can anyone explain to me why this code:

Code: [Select]
Dim NewLastPlayed as date
Dim d1 As DateTime = DateTime.Now
[more code]
NewLastPlayed = d1
MJFile.Set("Last Played", NewLastPlayed)

give me "01/01/1970 1.00" when the Last Played field is displayed in MC???

My PC system date and time is correct so I don't understand.

i think that is, because last played is not a date in that sence. but a valua that gives the amount of time (seconds) that has past since a certain date.

i think since JimH birth, wasnt it.  :)
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72436
  • Where did I put my teeth?

My grandchildren were born before then.
Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

i think that is, because last played is not a date in that sence. but a valua that gives the amount of time (seconds) that has past since a certain date.

thanks gappie

so I switched from date to integer and tried adding just some seconds: it's the time in seconds since 01/01/1970 01:00

now all I need is a function to convert any human readable date\time string (like "YYYY\MM\DD-HH:MM:SS", but I can format it as I like it) in seconds since 01/01/1970 01:00.
anyone has one handy? (i'm really lazy at writing code...)


Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

I created a script in the sample scripts that done something like this
take a look here
http://yabb.jriver.com/interact/index.php?topic=33020.msg280016#msg280016

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

Thanks Chriz,
but all I know is a little vbs, no C at all.

Even vb.net it's way too advanced for me, so there's no way I can use your example to write what I need.

I'm googling for something written in vb.net...

Thanks anyway.

I'm trying to write a script to sync playstats from a PocketPC (where I use a software player that can write what it plays to a txt file) back to MC.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

The script has two functions:
One to go one way and one to go the other...
I'll take a look at converting them to VB later this evening
Shouldn't take to long.

private System.DateTime ConvertUnixSecondsToDateTime(double unixTime)
    {
        // First make a System.DateTime equivalent to the UNIX Epoch.
        System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);

        // Add the number of seconds in UNIX timestamp to be converted.
        dateTime = dateTime.AddSeconds(unixTime).ToLocalTime();
       
        //Return Our DateTime
        return dateTime;
    } 
   
    private double ConvertDateTimeToUnixSeconds(System.DateTime date_time_convert)
    {     
        // First make a System.DateTime equivalent to the UNIX Epoch.
        DateTime date_time_base = new DateTime(1970,1,1,0,0,0,0);
       
        //Subtract seconds From Unix Epoch from our date, leaving us with just the number of seconds
        TimeSpan span = date_time_convert.ToUniversalTime() - date_time_base;

        // Return the number of seconds
        return (double)span.TotalSeconds;
    }

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

Thanks Chriz,
but all I know is a little vbs, no C at all.

Even vb.net it's way too advanced for me, so there's no way I can use your example to write what I need.

I'm googling for something written in vb.net...

Thanks anyway.

I'm trying to write a script to sync playstats from a PocketPC (where I use a software player that can write what it plays to a txt file) back to MC.
are you using vb 2005 .net. i did something that wrote the days gone since 1 jan 2000. it was fairly easy in vb.net. and seconds was just an other parameter. but ofcource that is something that disappeared in the bin.

i search a bit.
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

the function in vb. net is called datediff. gives the difference in whatever between two dates.
hope that it helps in your search
Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

are you using vb 2005 .net.

i'm using ChriZ scripting plugin, so you should ask him what I'm using... I have no idea ! 8)
Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518

wow .net rocks!!!

just found this using google:

(#10/10/1980#).subtract(#1/1/1970#).totalseconds

where 10/10/1980 is basically my Last Played value!!!
only one short line of code.... a lot of time ago, when I used to write some scripts it was not that easy!!!
now I have to find out how to add the hour:minute:second info, but, come to think of it, for all I care I could just use the YYYY\MM\DD part (I don't care exactly at what time I did play a file)

thanks ChriZ and Gappie for your support!
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580

i'm using ChriZ scripting plugin, so you should ask him what I'm using... I have no idea ! 8)
i dont use the marvelous plugin from Mr Crizz anymore. but it is thanks to that plugin, that i can say that now.
well, you could try this.
Code: [Select]
        Dim test As Long
        test = DateDiff(DateInterval.Second, #1/1/1970#, #1/2/1970#)
        MsgBox(test)
this gives 86400 when it is right (24 hours). of course the second date and time should be changed.

edit... lol
you found an other answer while i was typing. great.  :)
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Well done!

The DateTime Class is really good for that sort of thing.
I think by placing the hashes around the date you're creating a DateTime object.
Not seen it done that way before.

ThoBar

  • Citizen of the Universe
  • *****
  • Posts: 992
  • Was confishy

So... I just realised a couple of potential uses for this plugin, and want to be clear that it can be done in theory before I take the plunge...

1. Auto tag based on file location...
I'm ripping to a semi structured location (eg classical\composer\conductor or music\genre\artist\album). I'm thinking that while MC monitors these locations, it doesnt put all the info into the appropriate fields - which can take some time for me to get around to - and so it's awkward getting access to the newly ripped or d/l'd music. (background - a lot of my CD's dont appear in CD DBs, or the tagging is not as I'd wish - so can't use MC or similar to just rip+tag)

Auto-tagging would be a great intermediate step for me. Logic would be along the lines of ...

Code: [Select]
With all files in the ripped directory
  if filepath contains(Classical) then
    MyMediaType="Classical - New"
    Composer = <extractcomposerfrompath>
    Conductor = <extractconductorfrompath>
  else if filepath contains(Music) the
    MyMediaType="Music - New"
    Genre = <extractgenrefrompath>
    Artist = <extractArtistfrompath>
    Album = <extractAlbumfrompath>
  end if
End with
... or something along those lines

2. Auto-move newly tagged files to the appopriate file location
Look for a field.. say... TagStatus and move new files that have recently had their tagging completed to their proper disk location
Code: [Select]
With all files with TagStatus=1
  if filepath contains(Ripped) then
   if MyMediaType=Classical then
     if AlbumComposer(auto) does not contain "multiple" then
      <movefileto> (ClassicalDrive\Composer\FriendlyOpusName\Conductor-Soloists)
     else
      <movefileto> (ClassicalDrive\Classical\AlbumArtist(auto)\Albumname)
     end if
   else if MyMediaType=Music then
       .
       .
       .
// You get the picture


There was another, that I've momentarily forgotten, but can these be done do you think?


 
Logged

ThoBar

  • Citizen of the Universe
  • *****
  • Posts: 992
  • Was confishy

I guess this could also be used for auto-updating non-MC supported tags via 3rd party cli tools too... theories?
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

I think that should be possible.

ThoBar

  • Citizen of the Universe
  • *****
  • Posts: 992
  • Was confishy

Havent been able to connect to the D/L site (www.wikifortio.com) all day. Any chance of getting it put elsewhere?

C.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

I will re-upload it later today.
Pages: [1] 2   Go Up