0 Members and 1 Guest are viewing this topic.
Сорри если не в тему, но:- можно узнать структуру (SQLite format 3 UTF-8) AIMP2.db - а там желающие на свой страх и риск ... PS Можно официально выложить структуру таблицы ? С комментариями на мое мыло...
const MonthDays: array [Boolean] of TDayTable = ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));function IsLeapYear(Year: Word): Boolean;begin Result := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0));end;function TryEncodeDate(Year, Month, Day: Word; out Date: TDateTime): Boolean;var I: Integer; DayTable: PDayTable;begin Result := False; DayTable := @MonthDays[IsLeapYear(Year)]; if (Year >= 1) and (Year <= 9999) and (Month >= 1) and (Month <= 12) and (Day >= 1) and (Day <= DayTable^[Month]) then begin for I := 1 to Month - 1 do Inc(Day, DayTable^[I]); I := Year - 1; Date := I * 365 + I div 4 - I div 100 + I div 400 + Day - DateDelta; Result := True; end;end;function TryEncodeTime(Hour, Min, Sec, MSec: Word; out Time: TDateTime): Boolean;begin Result := False; if (Hour < HoursPerDay) and (Min < MinsPerHour) and (Sec < SecsPerMin) and (MSec < MSecsPerSec) then begin Time := (Hour * (MinsPerHour * SecsPerMin * MSecsPerSec) + Min * (SecsPerMin * MSecsPerSec) + Sec * MSecsPerSec + MSec) / MSecsPerDay; Result := True; end;end;function EncodeDate(Year, Month, Day: Word): TDateTime;begin if not TryEncodeDate(Year, Month, Day, Result) then ConvertError(@SDateEncodeError);end;function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;begin if not TryEncodeTime(Hour, Min, Sec, MSec, Result) then ConvertError(@STimeEncodeError);end;Result := EncodeDate(wYear, wMonth, wDay) + EncodeTime(wHour, wMinute, wSecond, wMilliseconds);
#!Perl -wuse DBI qw(:sql_types);use Encode;use strict;my $fn = 'c:\Documents and Settings\My User\Application Data\AIMP\ML\AIMP2.db';# CREATE TABLE MAIN (sFileName TEXT, sDrive CHAR, sTitle TEXT, sTrack TEXT, sDisk TEXT,# sArtist TEXT, sAlbum TEXT, sAlbumArtist TEXT, sYear TEXT, sGenre TEXT, SampleRate INT,# BitRate INT, Channels INT, FileSize INT, Duration INT, Mark INT, LastPlay DOUBLE, Added DOUBLE, PlayCount INT, Flags INT)my @field = qw(sFileName sDrive sTitle sTrack sDisk sArtist sAlbum sAlbumArtist sYear sGenre SampleRate BitRate Channels FileSize Duration Mark LastPlay Added PlayCount Flags);sub en{ # В какой кодировке вернуть encode("cp1251", $_[0]);}sub DecodeTime{ # Без поправок на ветер my $t = shift; my $delta_day = (1970-1900)*365+17; # С учетом високосных(17) лет! В Delphi с 1900, а у меня с 1970 $t = int (($t-$delta_day) * 24 * 60 * 60); scalar (localtime $t);}my $dbh = DBI->connect("dbi:SQLite:dbname=".$fn,"","");$dbh->{unicode} = 1; # Обязательно !my $all = $dbh->selectall_arrayref("SELECT * FROM MAIN");foreach my $row (@$all) { for (my $f = 0; $f< @field; $f++){ print $field[$f],"="; if ($f == 16 || $f == 17){ if ($$row[$f]!=0){ print DecodeTime($$row[$f]); } }else{ print en($$row[$f]); } print "\n"; } print "\n";}