Page 4 of 162

Posted: Tue Jul 24, 2007 6:26 pm
by Bex
Yeah, but I got annoyed....

Posted: Tue Jul 24, 2007 6:35 pm
by ZvezdanD
BTW, you didn't mentioned firstweekofyear. My code assume that a year start with week in which January 1 occurs (MS default setting). This not follow ISO standards, according to web page which you posted.

Posted: Tue Jul 24, 2007 6:48 pm
by Bex
Yes, I know but it's equally common to use 1 jan so i will use your code to give users other options!
More here:
http://en.wikipedia.org/wiki/Week#Week_number

Posted: Wed Jul 25, 2007 9:00 am
by ZvezdanD
Here is a replacement for Format(Date, "ww", firstdayofweek, firstweekofyear) in SQLite:

Code: Select all

cast(strftime('%W', Date) as integer) +
case when firstdayofweek = 1
then
    case when cast(strftime('%w', Date, 'start of year') as integer) = 1
    then
        0
    else
        1
    end
else
    case when cast(strftime('%w', Date, 'start of year') as integer) > 1
        and (firstdayofweek > cast(strftime('%w', Date, 'start of year') as integer)
        or firstdayofweek = 0)
    then
        case when cast(strftime('%w', Date) as integer) = 0
            or cast(strftime('%w', Date) as integer) >= firstdayofweek
            and firstdayofweek > cast(strftime('%w', Date, 'start of year') as integer)
        then
            2
        else
            1
        end
    else
        case when cast(strftime('%w', Date) as integer) = 0
            or cast(strftime('%w', Date) as integer) >= firstdayofweek 
            and firstdayofweek > 0
        then
            1
        else
            0
        end
    end
end +
case when firstweekofyear = 2
    and cast(strftime('%j', Date, 'start of year', 'weekday ' 
    || cast(firstdayofweek as text), '-1 day') as integer) < 4
    or firstweekofyear = 3
    and cast(strftime('%w', Date, 'start of year') as integer) <> firstdayofweek
then
    case when date(Date, 'start of year', 'weekday ' || cast(firstdayofweek as text)) 
        > Date
    then
        case when firstweekofyear = 2
            and cast(strftime('%j', Date, 'start of year', '-1 year', 'weekday '
            || cast(firstdayofweek as text), '-1 day') as integer) < 4
            or firstweekofyear = 3
            and cast(strftime('%w', Date, 'start of year', '-1 year') as integer)
            <> firstdayofweek
            and cast(strftime('%w', Date, 'start of year', '-1 day') as integer)
            <> firstdayofweek
        then
            51
        else
            52
        end
    else
        -1
    end
else
    0
end
firstdayofweek has same value as in SQLite (0 - Sunday, 1 - Monday...), but firstweekofyear has same value as in MS Jet (1 - Start with week in which January 1 occurs (default), 2 - Start with the first week that has at least four days in the year, 3 - Start with the first full week of the year).

Posted: Wed Jul 25, 2007 9:36 am
by Bex
Thanks, I'll check it out later!

Posted: Wed Jul 25, 2007 10:29 am
by ZvezdanD
I think that I found a bug in the MS algorithm. If you choose firstweekofyear = 2 or 3, the last day of the first week on the begin of year 2101 has incorrect a week of year. Please, take a look on an example with firstweekofyear =2 and firstdayofweek = 2 (Mon), where 2101-01-02 has value 53 instead of 52:

Code: Select all

             Sat Sun Mon Tue Wed Thu Fri
2100-12-11 - 49, 49, 50, 50, 50, 50, 50
2100-12-18 - 50, 50, 51, 51, 51, 51, 51
2100-12-25 - 51, 51, 52, 52, 52, 52, 52
2101-01-01 - 52, 53, 01, 01, 01, 01, 01
2101-01-08 - 01, 01, 02, 02, 02, 02, 02
2101-01-15 - 02, 02, 03, 03, 03, 03, 03
2101-01-22 - 03, 03, 04, 04, 04, 04, 04

Posted: Wed Jul 25, 2007 1:48 pm
by Bex
Yeah, I've read that MS has bugs in its date calculation engine. In this case it doesn't matter since it's very far in the future.

Posted: Thu Jul 26, 2007 5:04 pm
by ZvezdanD
There is a new 1.4.3 version with a link in the first post of this thread.

Posted: Fri Jul 27, 2007 2:39 am
by nojac
DELETED Download error...

(I downloaded the new version, but I got an error message and nothing worked any more. I assumed it was a script error. But after a new download everything worked OK.
Therefore I deleted the original message... )

Posted: Fri Jul 27, 2007 3:18 am
by ZvezdanD
Please, if you want to help me, you should tell me more: which mask are you using, which MM version, are you tried same mask with last official script, what kind of files you have (mp3, ogg, flac...), what action did you tried...

From this what you wrote, I suppose that you are trying mask with <format>. In the script there is no such thing as "WHEN substr(Songpath,-3,1)=','", but only "WHEN substr(Songpath, -3, 1) = '.' ". How did you got "," instead of "."?

Posted: Fri Jul 27, 2007 4:14 am
by nojac
DELETED I reloaded and now it works as it should!

Sorry about this. Removed my former post about this...

Posted: Fri Jul 27, 2007 6:07 am
by ZvezdanD
Sorry, but I don't really have any clue for this. I think that your download is corrupted. Please, check if a file size of VBS file is 91.168 bytes. If it is not, try to download the script again. Also, you could send me on PM your MM INI file (c:\Documents and Settings\Your_name\Local Settings\Application Data\MediaMonkey\MediaMonkey.ini), or just lines inside of the [CustomNodeMasks] section.

Posted: Fri Jul 27, 2007 7:47 am
by Vyper
I love your new modified version but have run into a minor problem. I have a number of magic nodes that all still work except for this one which is supposed to list my albums that have 'Various Artists' as the album artist:

Code: Select all

Album Artists Various|child of:artist|SQL filter:artist='Various Artists'\<Album Artist>\<Album|Sort by:max(year)>

I get these errors, one right after the after:


Image

Image

Image


Can you tell me how to modify this node to work with your new code?

Any help would be much appreciated. :D

Posted: Fri Jul 27, 2007 1:30 pm
by ZvezdanD
Vyper wrote:I have a number of magic nodes that all still work except for this one which is supposed to list my albums that have 'Various Artists' as the album artist:

Code: Select all

Album Artists Various|child of:artist|SQL filter:artist='Various Artists'\<Album Artist>\<Album|Sort by:max(year)>
There is a new 1.4.3.1 version which has fixed error. Thank you very much for the report.

Posted: Fri Jul 27, 2007 1:45 pm
by Vyper
Now there is a serious problem. Updating the script, then running Media Monkey, MM acts as if MagicNodes is not installed at all. No nodes listed, no options, nothing. And I do have it in the scripts/auto folder. :(