Auto/SelectionOfTheDay.vbs

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Auto/SelectionOfTheDay.vbs

Re: Auto/SelectionOfTheDay.vbs

Post by Eyal » Fri Feb 18, 2011 2:02 am

Hi,

Try replacing line 348 with this one:
Code: Select all
Set SongsIDs = SDB.Database.OpenSQL("SELECT Songs.ID FROM Songs WHERE Genre NOT IN('Podcast', 'Audiobook') ORDER BY Songs.ID")


You need to restart MM after modifying auto scripts.

Re: Auto/SelectionOfTheDay.vbs

Post by kmleo » Thu Feb 17, 2011 10:08 am

I have the same issue as the above poster. I would like to filter out the podcasts and audiobooks from my list. I think the SQL code I got from one of my Magic Nodes will work. I modified the SQL call in one of the subfunctions like so:

Subfunction begins at line 328:
Code: Select all
Sub FillTodaySong(Node)
[...]

[Line349]
Set SongsIDs = SDB.Database.OpenSQL("SELECT Songs.ID FROM Songs WHERE Songs.ID NOT IN (SELECT Songs.ID FROM Songs, GenresSongs, Genres WHERE Songs.ID = GenresSongs.IDSong AND GenresSongs.IDGenre = Genres.IDGenre AND Genres.GenreName IN ('Podcast', 'Audiobook'))")   


The error I get reads like this:

There was a problem querying the database:
Error executing SQL "SELECT Songs.*
FROM Songs
WHERE Songs.ID IN (30, 37, 66, 86, 96, 117, 231, 380,,,,,,,,) ORDER BY Songs.SongTitle
":near ",":syntax error(1,1)


Any thoughts on where I went wrong? I'm not a VBS programmer, so this is a little baffling to me....

Thanks for your assistance!
Krista

Re: Auto/SelectionOfTheDay.vbs

Post by Senpai3330 » Mon Jul 13, 2009 9:59 am

Hey Great script! I always wanted something like this to rediscover old favorites.

I have a feature to request though. Is there a way to filter out certain genres?

Podcasts/Audiobooks/Soundtracks keep showing up for me :-?

Re: Auto/SelectionOfTheDay.vbs

Post by Bex » Sun Sep 21, 2008 5:49 pm

I've only changed the sql used in the script but this should do it:
Code: Select all
    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
    '
    '                  "Auto/SelectionOfTheDay.vbs", Sept-01-2004
    '         VBScript for MediaMonkey MM3 (or above), written by Octopod
    '         MM3 support added by Bex (2008-09-22)
    '
    ' Purpose:
    ' - This script adds a new tree node named "Today..." after the Playlists one
    ' - Each time you start MediaMonkey: an artist, an album and 14 songs (default)
    '   are randomly selected from the entire DB
    ' - If you don't like the selection of the day, a toolbar icon can be enabled to
    '   re-randomize it ("Standard" toolbar)
    ' - If you do not change the used strings, this script is localization-compatible
    ' - Hope you will enjoy it!
    '
    ' Known issue:
    ' - If a "today sub-node" is already selected when randomize is manually forced:
    '   1. Bad node selection refresh
    '   2. Tracks list is not updated (need to hit 'F5' or change node)
    '
    ' Notes:
    ' - This script uses registry keys because i did not succeeded in retrieving a
    '   global value from the nodes callbacks
    ' - This script may be not or badly optimized as i do not know VBS
    ' - So, and although this script should be safe, USE AT YOUR OWN RISK
    '
    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


    ' --> Number of songs you want to be proposed?
    NbSongs = 14

    ' --> Expand the node at startup?
    ExpandNewNode = False

    ' --> Explicit nodes caption?
    ExplicitCaption = True

    ' --> Enable re-randomize?
    EnableReRandomize = False


    ' Globals (cardinals)
    Dim ArtistsCardinal
    Dim AlbumsCardinal
    Dim SongsCardinal

    ' Globals (random positions)
    Dim SelectedArtistPos
    Dim SelectedAlbumPos
    Dim SelectedSongsPos()


    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


    Sub OnStartup

      Dim Tree
      Set Tree = SDB.MainTree

      ' Main node
      Set Node_Today = Tree.CreateNode
      Node_Today.Caption = SDB.Localize("Today") + "..."
      Node_Today.IconIndex = 49
      Node_Today.UseScript = Script.ScriptPath
      Tree.AddNode Tree.Node_Playlists, Node_Today, 1
      SDB.Objects("Node_Today") = Node_Today

      ' Subnode 1 (Artist)
      Set Node_TodayArtist = Tree.CreateNode
      Node_TodayArtist.Caption = SDB.Localize("Artist")
      Node_TodayArtist.IconIndex = 0
      Node_TodayArtist.UseScript = Script.ScriptPath
      Node_TodayArtist.OnFillTracksFunct = "FillTodayArtist"
      Tree.AddNode Node_Today, Node_TodayArtist, 3
      SDB.Objects("Node_TodayArtist") = Node_TodayArtist

      ' Subnode 2 (Album)
      Set Node_TodayAlbum = Tree.CreateNode
      Node_TodayAlbum.Caption = SDB.Localize("Album")
      Node_TodayAlbum.IconIndex = 16
      Node_TodayAlbum.UseScript = Script.ScriptPath
      Node_TodayAlbum.OnFillTracksFunct = "FillTodayAlbum"
      Tree.AddNode Node_Today, Node_TodayAlbum, 3
      SDB.Objects("Node_TodayAlbum")  = Node_TodayAlbum
     
      ' Subnode 3 (Songs)
      Set Node_TodaySong = Tree.CreateNode
      If (ExplicitCaption) Then
        Node_TodaySong.Caption = "(" + CStr(NbSongs) + " " + SDB.Localize("tracks") + ")"
      Else
        Node_TodaySong.Caption = SDB.Localize("Title")
      End If
      Node_TodaySong.IconIndex = 3
      Node_TodaySong.UseScript = Script.ScriptPath
      Node_TodaySong.OnFillTracksFunct = "FillTodaySong"
      Tree.AddNode Node_Today, Node_TodaySong, 3

      If (EnableReRandomize) Then
        ' Add a button to the Standard toolbar...
        Set UI = SDB.UI
        UI.AddMenuItemSep UI.Menu_TbStandard, -1, 0
        Set Mnu = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
        Mnu.UseScript = Script.ScriptPath
        Mnu.OnClickFunc = "ForceNewSelection"
        Mnu.IconIndex = 45
        Mnu.Hint = SDB.Localize("Today") + "..."
      End If
     
      ' Prepare selection at startup
      Node_Today.Expanded = ExpandNewNode
      NewSelection(dummy)

    End Sub


    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


    Sub NewSelection(arg)

      InitCardinals
      InitSelections
     
      ' Explicit caption
      If (ExplicitCaption) Then

        Dim ID

        ' Artist
        Set Node_TodayArtist = SDB.Objects("Node_TodayArtist")
        ID = GetArtistID(SelectedArtistPos)
        Set ArtistName = SDB.Database.OpenSQL("SELECT Artists.Artist FROM Artists WHERE Tracks>0 AND Artists.ID = " + CStr(ID))
        Node_TodayArtist.Caption = ArtistName.StringByIndex(0)
       
        ' Album
        Set Node_TodayAlbum = SDB.Objects("Node_TodayAlbum")
        ID = GetAlbumID(SelectedAlbumPos)
        Set AlbumName = SDB.Database.OpenSQL("SELECT Albums.Album FROM Albums WHERE Albums.ID = " + CStr(ID))
        Node_TodayAlbum.Caption = AlbumName.StringByIndex(0)

      End If

    End Sub


    Sub ForceNewSelection(arg)

      NewSelection(arg)
     
      ' Force explicit captions refresh
      If (EnableReRandomize) Then
        ' Main node
        Set Node_Today = SDB.Objects("Node_Today")
        If (Node_Today.Expanded) Then
          Node_Today.Expanded = False
          Node_Today.Expanded = True
        End If
      End If

    End Sub


    Sub InitCardinals

      ' Artists (remove ID = 0 = "Unknown" artist)
      Set AllArtists = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Artists WHERE Tracks>0")
      ArtistsCardinal = AllArtists.StringByIndex(0)

      ' Albums (remove ID = 0 = "Unknown" album)
      Set AllAlbums = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Albums WHERE Tracks>0")
      AlbumsCardinal = AllAlbums.StringByIndex(0)

      ' Songs
      Set AllSongs = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Songs")
      SongsCardinal = AllSongs.StringByIndex(0)

    End Sub


    Sub InitSelections

      Randomize

      ' Randomly select a **position** within artists IDs records
      SelectedArtistPos = Int(Rnd * ArtistsCardinal)

      ' Randomly select **position** within albums IDs records
      SelectedAlbumPos = Int(Rnd * AlbumsCardinal)
     
      ' Randomly select "NbSongs" **positions** within songs IDs records
      ReDim SelectedSongsPos(NbSongs)
      For i = 1 to NbSongs
        SelectedSongsPos(i) = Int(Rnd * SongsCardinal)
      Next
     
      ' Bubble sort
      ' (sort positions to speed up songs display; only one loop)
      Dim count, i, j, temp
      count = UBound(SelectedSongsPos, 1)
      For j = 0 To NbSongs - 1
        For i = 0 To NbSongs - 1
          If SelectedSongsPos(i) > SelectedSongsPos(i + 1) Then
            temp = SelectedSongsPos(i + 1)
            SelectedSongsPos(i + 1) = SelectedSongsPos(i)
            SelectedSongsPos(i) = temp
          End If
        Next
      Next

      ' Save selections
      Set Regs = SDB.Registry
      If Regs.OpenKey("SelectionOfTheDay", True) Then
        Regs.IntValue("SelectedArtistPos") = SelectedArtistPos
        Regs.IntValue("SelectedAlbumPos") = SelectedAlbumPos
        For i = 1 to NbSongs
          Regs.IntValue("SelectedSongsPos" + CStr(i)) = SelectedSongsPos(i)
        Next
        Regs.IntValue("SongsCardinal") = SongsCardinal
        Regs.CloseKey
      End If

    End Sub


    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


    Function GetArtistID(ArtistPos)

      ' Get all available artists IDs
      ' (This query is done in the callback to avoid slowing startup)
      Set ArtistsIDs = SDB.Database.OpenSQL("SELECT Artists.ID FROM Artists WHERE Tracks>0")

      ' Get its related **artist ID** (as position <> ID):

      ' 1. Forward to ArtistPos'th record
      For j = 1 to ArtistPos - 1
            ArtistsIDs.Next
      Next

      ' 2. Then get its related artist ID
      GetArtistID = ArtistsIDs.StringByIndex(0)

    End Function


    Sub FillTodayArtist(Node)

      ' Get back selected artist position
      Set Regs = SDB.Registry
      If Regs.OpenKey("SelectionOfTheDay", True) Then
        SelectedArtistPos = Regs.IntValue("SelectedArtistPos")
        Regs.CloseKey
      End If

      ' Get back related artist ID
      Dim ID
      ID = GetArtistID(SelectedArtistPos)

      ' Prepare query
      Dim ArtistQuery
      ArtistQuery = ", ArtistsSongs WHERE Songs.ID=IDSong AND PersonType=1 AND IDArtist="
      ArtistQuery = ArtistQuery + CStr(ID)
      ArtistQuery = ArtistQuery + " ORDER BY Songs.Year DESC, Songs.IDAlbum, DiscNumber COLLATE NUMERICSTRING, TrackNumber COLLATE NUMERICSTRING"

      ' Now, invoke query and update tracks list
      Set Tracks = SDB.MainTracksWindow
      Tracks.AddTracksFromQuery ArtistQuery
      Tracks.FinishAdding

    End Sub


    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


    Function GetAlbumID(AlbumPos)

      ' Get all available albums IDs
      ' (This query is done in the callback to avoid slowing startup)
      Set AlbumsIDs = SDB.Database.OpenSQL("SELECT Albums.ID FROM Albums WHERE Tracks>0")

      ' Get its related **album ID** (as position <> ID):

      ' 1. Forward to SelectedAlbumPos'th record
      For j = 1 to SelectedAlbumPos - 1
            AlbumsIDs.Next
      Next

      ' 2. Then get its related album ID
      GetAlbumID = AlbumsIDs.StringByIndex(0)
       
    End Function


    Sub FillTodayAlbum(Node)

      ' Get back selected album position
      Set Regs = SDB.Registry
      If Regs.OpenKey("SelectionOfTheDay", True) Then
        SelectedAlbumPos = Regs.IntValue("SelectedAlbumPos")
        Regs.CloseKey
      End If

      ' Get back related album ID
      Dim ID
      ID = GetAlbumID(SelectedAlbumPos)

      ' Prepare query
      Dim AlbumQuery
      AlbumQuery = "WHERE Songs.IDAlbum = "
      AlbumQuery = AlbumQuery + CStr(ID)
      AlbumQuery = AlbumQuery + " ORDER BY DiscNumber COLLATE NUMERICSTRING, TrackNumber COLLATE NUMERICSTRING"

      ' Now, invoke query and update tracks list
      Set Tracks = SDB.MainTracksWindow
      Tracks.AddTracksFromQuery AlbumQuery
      Tracks.FinishAdding

    End Sub


    ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


    Sub FillTodaySong(Node)

      ReDim SelectedSongsPos(NbSongs)

      Dim tempo
      tempo = ""

      ' Get back selected songs positions
      Set Regs = SDB.Registry
      If Regs.OpenKey("SelectionOfTheDay", True) Then
        For i = 1 to NbSongs
          SelectedSongsPos(i) = Regs.IntValue("SelectedSongsPos" + CStr(i))
          tempo = tempo + CStr(SelectedSongsPos(i)) + " / "
        Next
        SongsCardinal = Regs.IntValue("SongsCardinal")
        Regs.CloseKey
      End If

      ' Get all available songs IDs
      ' (This query is done in the callback to avoid slowing startup)
      Set SongsIDs = SDB.Database.OpenSQL("SELECT Songs.ID FROM Songs ORDER BY Songs.ID")

      ' Store IDs
      ReDim IDList(NbSongs)
      Dim IDCardinal
      IDCardinal = 0

      ' Current position counter
      Dim NextID
      NextID = 1
     
      ' Forward along the iterator
      ' (This block is a bit complex but its aim is to avoid browsing the iterator
      '  several times, so display of the selected tracks will be faster)
      For j = 0 to (SongsCardinal - 1)

        ' Check if the current item is selected ("SelectedSongsPos" is sorted)
        If (j = SelectedSongsPos(NextID)) Then

          IDList(IDCardinal) = SongsIDs.StringByIndex(0)
          IDCardinal = IDCardinal + 1

          ' Break loop if all IDs already found
          If (NextID = NbSongs) Then
            Exit For
          End If

          ' Otherwise, update next position to reach
          NextID = NextID + 1
         
          ' Check if douboons in the subsequent cells
          If (NextID < NbSongs) Then
            While (SelectedSongsPos(NextID) = SelectedSongsPos(NextID + 1))
              NextID = NextID + 1
            WEnd
          End If
           
        End If
       
        ' Continue...
        SongsIDs.Next
     
      Next
     
      ' Prepare query
      Dim SongQuery
      SongQuery = "WHERE Songs.ID IN ("
      For i = 0 to (IDCardinal - 2)
        SongQuery = SongQuery + CStr(IDList(i)) + ", "
      Next
      SongQuery = SongQuery + CStr(IDList(IDCardinal - 1)) + ") ORDER BY Songs.SongTitle"
     
      ' Now, invoke query and update tracks list
      Set Tracks = SDB.MainTracksWindow
      Tracks.AddTracksFromQuery SongQuery
      Tracks.FinishAdding

      ' Because of possible doubloons and/or ghost songs IDs,
      ' less than "NbSongs" songs might be proposed

    End Sub

Re: Auto/SelectionOfTheDay.vbs

Post by Siggiminator » Sun Sep 21, 2008 4:41 pm

Well the code does not seem to be too difficult - I am sure it is just a command compatibility issue... If anyone if some scripting abilities could please have a look at this - I really like the idea behind this!

thx

Re: mm3

Post by Guest » Fri Feb 22, 2008 7:34 pm

jsummers wrote:I take this is not working with MM3?
I was just going to post something here to mention that this script appears to not work with MM3... Any chance of it being made compatible? I really enjoyed this script with MM2...

mm3

Post by jsummers » Wed Jan 16, 2008 2:25 pm

I take this is not working with MM3?

Post by kasnki » Thu Mar 02, 2006 3:57 am

Very very good! :D

Please add feature: Artists with several songs not displayed, because if you have many compiliation albums, where one artist - one track, then offen in artist node displayed one track. Add setting "Displayed artist with minimum tracks".

thx.

Post by al_iguana » Mon Feb 21, 2005 2:02 pm

this is superb - just what i was looking for!

(using the first version because all my music is on my pc too)

thanks a million :D

Post by Guest » Tue Sep 14, 2004 12:04 pm

Tell if it's ok now!

Thanks Octopod. But it is still displaying tracks from CDs. Here are the error messages I get--

Problem quereying the database:
42000:[Microsoft][ODBC] Microsoft Acess Driver Syntax Error in FROM clause
--------------------------------------------------------------

Error#-2147418113-DongsDB.SDBDBIterator
List Index out of bounds (0)
File:.....\SelectionOfTheDay.vbs Line:174, column 4
------------------------------------------------------------

Maybe I did not substitute the new text in the correct way?

llwb[/quote]

Post by Octopod » Fri Sep 10, 2004 1:39 pm

llwb,

Here is a version i tested a bit.

It uses as distinguishing criteria: "Songs.AudioCDTrack <= 0".
This should not be enough as you can set all your CD tracks order to 0...

In this case try replacing all "Songs.AudioCDTrack <= 0" instances by "Songs.SongPath NOT LIKE '%.cda'" (that should be a bit slower but better though).

Tell if it's ok now!

Octopod

Code: Select all
' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
'
'                  "Auto/SelectionOfTheDay.vbs", Sept-01-2004
'         VBScript for MediaMonkey 2.2.2 (or above), written by Octopod
'
'
' Purpose:
' - This script adds a new tree node named "Today..." after the Playlists one
' - Each time you start MediaMonkey: an artist, an album and 14 songs (default)
'   are randomly selected from the entire DB
' - If you don't like the selection of the day, a toolbar icon can be enabled to
'   re-randomize it ("Standard" toolbar)
' - If you do not change the used strings, this script is localization-compatible
' - Hope you will enjoy it!
'
' Known issue:
' - If a "today sub-node" is already selected when randomize is manually forced:
'   1. Bad node selection refresh
'   2. Tracks list is not updated (need to hit 'F5' or change node)
'
' Notes:
' - This script uses registry keys because i did not succeeded in retrieving a
'   global value from the nodes callbacks
' - This script may be not or badly optimized as i do not know VBS
' - So, and although this script should be safe, USE AT YOUR OWN RISK
'
' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


' --> Number of songs you want to be proposed?
NbSongs = 14

' --> Expand the node at startup?
ExpandNewNode = False

' --> Explicit nodes caption?
ExplicitCaption = True

' --> Enable re-randomize?
EnableReRandomize = False

' --> Forget CDs?
ForgetCD = True


' Globals (cardinals)
Dim ArtistsCardinal
Dim AlbumsCardinal
Dim SongsCardinal

' Globals (random positions)
Dim SelectedArtistPos
Dim SelectedAlbumPos
Dim SelectedSongsPos()


' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


Sub OnStartup

  Dim Tree
  Set Tree = SDB.MainTree

  ' Main node
  Set Node_Today = Tree.CreateNode
  Node_Today.Caption = "TODAY (NO CD)" 'SDB.Localize("Today") + "..."
  Node_Today.IconIndex = 49
  Node_Today.UseScript = Script.ScriptPath
  Tree.AddNode Tree.Node_Playlists, Node_Today, 1
  SDB.Objects("Node_Today") = Node_Today

  ' Subnode 1 (Artist)
  Set Node_TodayArtist = Tree.CreateNode
  Node_TodayArtist.Caption = SDB.Localize("Artist")
  Node_TodayArtist.IconIndex = 0
  Node_TodayArtist.UseScript = Script.ScriptPath
  Node_TodayArtist.OnFillTracksFunct = "FillTodayArtist"
  Tree.AddNode Node_Today, Node_TodayArtist, 3
  SDB.Objects("Node_TodayArtist") = Node_TodayArtist

  ' Subnode 2 (Album)
  Set Node_TodayAlbum = Tree.CreateNode
  Node_TodayAlbum.Caption = SDB.Localize("Album")
  Node_TodayAlbum.IconIndex = 16
  Node_TodayAlbum.UseScript = Script.ScriptPath
  Node_TodayAlbum.OnFillTracksFunct = "FillTodayAlbum"
  Tree.AddNode Node_Today, Node_TodayAlbum, 3
  SDB.Objects("Node_TodayAlbum")  = Node_TodayAlbum
 
  ' Subnode 3 (Songs)
  Set Node_TodaySong = Tree.CreateNode
  If (ExplicitCaption) Then
    Node_TodaySong.Caption = "(" + CStr(NbSongs) + " " + SDB.Localize("tracks") + ")"
  Else
    Node_TodaySong.Caption = SDB.Localize("Title")
  End If
  Node_TodaySong.IconIndex = 3
  Node_TodaySong.UseScript = Script.ScriptPath
  Node_TodaySong.OnFillTracksFunct = "FillTodaySong"
  Tree.AddNode Node_Today, Node_TodaySong, 3

  If (EnableReRandomize) Then
    ' Add a button to the Standard toolbar...
    Set UI = SDB.UI
    UI.AddMenuItemSep UI.Menu_TbStandard, -1, 0
    Set Mnu = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
    Mnu.UseScript = Script.ScriptPath
    Mnu.OnClickFunc = "ForceNewSelection"
    Mnu.IconIndex = 45
    Mnu.Hint = SDB.Localize("Today") + "..."
  End If
 
  ' Prepare selection at startup
  Node_Today.Expanded = ExpandNewNode
  NewSelection(dummy)

End Sub


' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


Sub NewSelection(arg)

  InitCardinals
  InitSelections
 
  ' Explicit caption
  If (ExplicitCaption) Then

    Dim ID

    ' Artist
    Set Node_TodayArtist = SDB.Objects("Node_TodayArtist")
    ID = GetArtistID(SelectedArtistPos)
    Set ArtistName = SDB.Database.OpenSQL("SELECT Artists.Artist FROM Artists WHERE Artists.ID = " + CStr(ID))
    Node_TodayArtist.Caption = ArtistName.StringByIndex(0)
   
    ' Album
    Set Node_TodayAlbum = SDB.Objects("Node_TodayAlbum")
    ID = GetAlbumID(SelectedAlbumPos)
    Set AlbumName = SDB.Database.OpenSQL("SELECT Albums.Album FROM Albums WHERE Albums.ID = " + CStr(ID))
    Node_TodayAlbum.Caption = AlbumName.StringByIndex(0)

  End If

End Sub


Sub ForceNewSelection(arg)

  NewSelection(arg)
 
  ' Force explicit captions refresh
  If (EnableReRandomize) Then
    ' Main node
    Set Node_Today = SDB.Objects("Node_Today")
    If (Node_Today.Expanded) Then
      Node_Today.Expanded = False
      Node_Today.Expanded = True
    End If
  End If

End Sub


Sub InitCardinals

  If (ForgetCD) Then
 
    ' Artists (remove ID = 0 = "Unknown" artist)
    Set AllArtists = SDB.Database.OpenSQL("SELECT COUNT(Artists.ID) FROM (SELECT DISTINCTROW Artists.ID FROM (artists INNER JOIN Songs ON artists.ID = Songs.IDArtist) WHERE artists.ID <> 0 AND Songs.AudioCDTrack <= 0)")
    ArtistsCardinal = AllArtists.StringByIndex(0)

    ' Albums (remove ID = 0 = "Unknown" album)
    Set AllAlbums = SDB.Database.OpenSQL("SELECT COUNT(*) FROM (SELECT DISTINCTROW Albums.ID FROM (albums INNER JOIN Songs ON albums.ID = Songs.IDAlbum) WHERE albums.ID <> 0 AND Songs.AudioCDTrack <= 0)")
    AlbumsCardinal = AllAlbums.StringByIndex(0)

    ' Songs
    Set AllSongs = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Songs WHERE Songs.AudioCDTrack <= 0")
    SongsCardinal = AllSongs.StringByIndex(0)
 
  Else

    ' Artists (remove ID = 0 = "Unknown" artist)
    Set AllArtists = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Artists WHERE Artists.ID <> 0")
    ArtistsCardinal = AllArtists.StringByIndex(0)

    ' Albums (remove ID = 0 = "Unknown" album)
    Set AllAlbums = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Albums WHERE Albums.ID <> 0")
    AlbumsCardinal = AllAlbums.StringByIndex(0)

    ' Songs
    Set AllSongs = SDB.Database.OpenSQL("SELECT COUNT(*) FROM Songs")
    SongsCardinal = AllSongs.StringByIndex(0)
 
  End If

End Sub


Sub InitSelections

  Randomize

  ' Randomly select a **position** within artists IDs records
  SelectedArtistPos = Int(Rnd * ArtistsCardinal)

  ' Randomly select **position** within albums IDs records
  SelectedAlbumPos = Int(Rnd * AlbumsCardinal)
 
  ' Randomly select "NbSongs" **positions** within songs IDs records
  ReDim SelectedSongsPos(NbSongs)
  For i = 1 to NbSongs
    SelectedSongsPos(i) = Int(Rnd * SongsCardinal)
  Next
 
  ' Bubble sort
  ' (sort positions to speed up songs display; only one loop)
  Dim count, i, j, temp
  count = UBound(SelectedSongsPos, 1)
  For j = 0 To NbSongs - 1
    For i = 0 To NbSongs - 1
      If SelectedSongsPos(i) > SelectedSongsPos(i + 1) Then
        temp = SelectedSongsPos(i + 1)
        SelectedSongsPos(i + 1) = SelectedSongsPos(i)
        SelectedSongsPos(i) = temp
      End If
    Next
  Next

  ' Save selections
  Set Regs = SDB.Registry
  If Regs.OpenKey("SelectionOfTheDay", True) Then
    Regs.IntValue("SelectedArtistPos") = SelectedArtistPos
    Regs.IntValue("SelectedAlbumPos") = SelectedAlbumPos
    For i = 1 to NbSongs
      Regs.IntValue("SelectedSongsPos" + CStr(i)) = SelectedSongsPos(i)
    Next
    Regs.IntValue("SongsCardinal") = SongsCardinal
    Regs.CloseKey
  End If

End Sub


' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


Function GetArtistID(ArtistPos)

  ' Get all available artists IDs
  ' (This query is done in the callback to avoid slowing startup)

  If (ForgetCD) Then
 
    Set ArtistsIDs = SDB.Database.OpenSQL("SELECT Artists.ID FROM (artists INNER JOIN Songs ON artists.ID = Songs.IDArtist) WHERE artists.ID <> 0 AND Songs.AudioCDTrack <= 0")
 
  Else

    Set ArtistsIDs = SDB.Database.OpenSQL("SELECT Artists.ID FROM Artists WHERE Artists.ID <> 0")
   
  End If

  ' Get its related **artist ID** (as position <> ID):

  ' 1. Forward to ArtistPos'th record
  For j = 1 to ArtistPos - 1
        ArtistsIDs.Next
  Next

  ' 2. Then get its related artist ID
  GetArtistID = ArtistsIDs.StringByIndex(0)

End Function


Sub FillTodayArtist(Node)

  ' Get back selected artist position
  Set Regs = SDB.Registry
  If Regs.OpenKey("SelectionOfTheDay", True) Then
    SelectedArtistPos = Regs.IntValue("SelectedArtistPos")
    Regs.CloseKey
  End If

  ' Get back related artist ID
  Dim ID
  ID = GetArtistID(SelectedArtistPos)

  ' Prepare query
  Dim ArtistQuery
  ArtistQuery = "AND Songs.IDArtist = "
  ArtistQuery = ArtistQuery + CStr(ID)
  ArtistQuery = ArtistQuery + " ORDER BY Songs.Year DESC, Songs.IDAlbum, Songs.SongOrder"

  ' Now, invoke query and update tracks list
  Set Tracks = SDB.MainTracksWindow
  Tracks.AddTracksFromQuery ArtistQuery
  Tracks.FinishAdding

End Sub


' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


Function GetAlbumID(AlbumPos)

  ' Get all available albums IDs
  ' (This query is done in the callback to avoid slowing startup)
 
  If (ForgetCD) Then
 
    Set AlbumsIDs = SDB.Database.OpenSQL("SELECT Albums.ID FROM (albums INNER JOIN Songs ON albums.ID = Songs.IDAlbum) WHERE albums.ID <> 0 AND Songs.AudioCDTrack <= 0")
   
  Else
 
    Set AlbumsIDs = SDB.Database.OpenSQL("SELECT Albums.ID FROM Albums WHERE Albums.ID <> 0")
   
  End If

  ' Get its related **album ID** (as position <> ID):

  ' 1. Forward to SelectedAlbumPos'th record
  For j = 1 to SelectedAlbumPos - 1
        AlbumsIDs.Next
  Next

  ' 2. Then get its related album ID
  GetAlbumID = AlbumsIDs.StringByIndex(0)
   
End Function


Sub FillTodayAlbum(Node)

  ' Get back selected album position
  Set Regs = SDB.Registry
  If Regs.OpenKey("SelectionOfTheDay", True) Then
    SelectedAlbumPos = Regs.IntValue("SelectedAlbumPos")
    Regs.CloseKey
  End If

  ' Get back related album ID
  Dim ID
  ID = GetAlbumID(SelectedAlbumPos)

  ' Prepare query
  Dim AlbumQuery
  AlbumQuery = "AND Songs.IDAlbum = "
  AlbumQuery = AlbumQuery + CStr(ID)
  AlbumQuery = AlbumQuery + " ORDER BY Songs.SongOrder"

  ' Now, invoke query and update tracks list
  Set Tracks = SDB.MainTracksWindow
  Tracks.AddTracksFromQuery AlbumQuery
  Tracks.FinishAdding

End Sub


' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----


Sub FillTodaySong(Node)

  ReDim SelectedSongsPos(NbSongs)

  Dim tempo
  tempo = ""

  ' Get back selected songs positions
  Set Regs = SDB.Registry
  If Regs.OpenKey("SelectionOfTheDay", True) Then
    For i = 1 to NbSongs
      SelectedSongsPos(i) = Regs.IntValue("SelectedSongsPos" + CStr(i))
      tempo = tempo + CStr(SelectedSongsPos(i)) + " / "
    Next
    SongsCardinal = Regs.IntValue("SongsCardinal")
    Regs.CloseKey
  End If

  ' Get all available songs IDs
  ' (This query is done in the callback to avoid slowing startup)
 
  If (ForgetCD) Then

    Set SongsIDs = SDB.Database.OpenSQL("SELECT Songs.ID FROM Songs WHERE Songs.AudioCDTrack <= 0 ORDER BY Songs.ID")
   
  Else
 
    Set SongsIDs = SDB.Database.OpenSQL("SELECT Songs.ID FROM Songs ORDER BY Songs.ID")
   
  End If
 
  ' Store IDs
  ReDim IDList(NbSongs)
  Dim IDCardinal
  IDCardinal = 0

  ' Current position counter
  Dim NextID
  NextID = 1
 
  ' Forward along the iterator
  ' (This block is a bit complex but its aim is to avoid browsing the iterator
  '  several times, so display of the selected tracks will be faster)
  For j = 0 to (SongsCardinal - 1)

    ' Check if the current item is selected ("SelectedSongsPos" is sorted)
    If (j = SelectedSongsPos(NextID)) Then

      IDList(IDCardinal) = SongsIDs.StringByIndex(0)
      IDCardinal = IDCardinal + 1

      ' Break loop if all IDs already found
      If (NextID = NbSongs) Then
        Exit For
      End If

      ' Otherwise, update next position to reach
      NextID = NextID + 1
     
      ' Check if douboons in the subsequent cells
      If (NextID < NbSongs) Then
        While (SelectedSongsPos(NextID) = SelectedSongsPos(NextID + 1))
          NextID = NextID + 1
        WEnd
      End If
       
    End If
   
    ' Continue...
    SongsIDs.Next
 
  Next
 
  ' Prepare query
  Dim SongQuery
  SongQuery = "AND Songs.ID IN ("
  For i = 0 to (IDCardinal - 2)
    SongQuery = SongQuery + CStr(IDList(i)) + ", "
  Next
  SongQuery = SongQuery + CStr(IDList(IDCardinal - 1)) + ") ORDER BY Songs.SongTitle"
 
  ' Now, invoke query and update tracks list
  Set Tracks = SDB.MainTracksWindow
  Tracks.AddTracksFromQuery SongQuery
  Tracks.FinishAdding

  ' Because of possible doubloons and/or ghost songs IDs,
  ' less than "NbSongs" songs might be proposed

End Sub

Post by Lowlander » Thu Sep 09, 2004 10:33 am

Often third parties. I own two TV's from different (I believe unrelated) brands and they have nearly identical remotes (some different buttons). This allows them to be cheap probably. Anyway the remote is often not the functionality your looking for, it accesses the functionality.

Lol

Post by TheRocket » Thu Sep 09, 2004 9:57 am

It seems to me that all remotes look like others :-)

This one is identical to the RemoteWonder by Ati...
And look like the Nvidia remonte :-)

Who is really making those remotes??? Anyway :-)

Post by Lowlander » Tue Sep 07, 2004 4:25 pm

Luckily I read German, very nice as it not only can control your PC as well as your other equipment.

thx

Post by Octopod » Tue Sep 07, 2004 4:17 pm

Here is what it looks like (i don't speak german myself...):
http://www.pearl.de/p/PE4444-Q-Sonic-Master-Remote-6in1-PC-Funk-Infrarot.html
http://www.pearl.fr/article-PE4444.html

I also bought a shareware named uICE (Universal Infrared Control Engine) to program it according to the active software.

I love it! 8)

Top