-
Notifications
You must be signed in to change notification settings - Fork 2
/
unit5.pas
140 lines (122 loc) · 4.58 KB
/
unit5.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
unit Unit5;
// stub files creating
{$mode objfpc}{$H+}
interface
uses
SysUtils, FileUtil, Forms, Controls, Dialogs, ExtCtrls, StdCtrls, EditBtn,{OmniXML,}
{OmniXMLUtils,} OXmlCDOM,OXmlUtils, Classes,LocalizedForms, LazUTF8;
type
{ TForm5 }
TForm5 = class(TLocalizedForm)
Button1: TButton; { OK}
Button2: TButton; { Cancel }
DirectoryEdit1: TDirectoryEdit; { umožňuje vybrat adresář }
Label1: TLabel;
LabeledEdit1: TLabeledEdit; {Alternative title - název seriálu}
LabeledEdit2: TLabeledEdit; {Message to be displayed - umístění}
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
protected
procedure UpdateTranslation(ALang: String); override;
end;
var
Form5: TForm5;
implementation
uses unit1; { chci pracovat s objekty Form1 }
{$R *.lfm}
{ TForm5 }
procedure TForm5.FormCreate(Sender: TObject);
begin
DirectoryEdit1.RootDir:= ( getCurrentDir); //systoutf8
DirectoryEdit1.Directory:=( getCurrentDir); // systoutf8
end;
procedure TForm5.FormShow(Sender: TObject);
begin
if Form1.ZQuery1.FieldByName('DRUH').AsString = 'series'
then
LabeledEdit1.Text:=Form1.ZQuery1.FieldByName('NAZEV_SERIALU').AsString
else
LabeledEdit1.Text:=Form1.ZQuery1.FieldByName('NAZEV').AsString;
LabeledEdit2.Text:=Form1.ZQuery1.FieldByName('UMISTENI').AsString;
end;
procedure TForm5.UpdateTranslation(ALang: String);
begin
inherited UpdateTranslation(ALang);
LabeledEdit1.EditLabel.Caption:=rsAlternativeT;
LabeledEdit2.EditLabel.Caption:=rsMessageToBeD;
end;
procedure TForm5.Button1Click(Sender: TObject); { OK a pak vytvoř stub soubor}
var
i: integer;
discstub: TXMLNode;
xmlDoc : IXMLDocument;
//pomSerieNazev : String;
PomS: String;
////--------------------------------------------------------------------
//// volitelně vytvořit druhý xml soubor nfo pro automatické zařazení
//// do tagu (třeba offline), nejde to v nfo by museli být všechny údaje o filmu
// nebo alespoň http adresa na informace o filmu a to dělat nebudu :-)
//----------------------------------------------------------------------
//procedure vytvorXMLsTagem(druhPolozky:String;nazevPolozky:String;
// nazevTagu:String);
// // druhPolozky movie nebo tvshow :
// // viz. http://kodi.wiki/view/NFO_files/movies
// // viz. http://kodi.wiki/view/NFO_files/tvshows
// var
// xmlDocTag:IXMLDocument;
// serieNeboFilm:TXMLNode;
// pomDir:String;
// pomFile:String;
// begin
// xmlDocTag:=CreateXMLDoc(druhPolozky); // movie nebo tvshow
// serieNeboFilm:=xmlDocTag.DocumentElement;
// serieNeboFilm.AddChild('tag').AddText(nazevTagu);
// pomDir:=DirectoryEdit1.Directory+PathDelim+nazevPolozky+PathDelim;
// if ForceDirectories(pomDir) then
// begin
// pomFile:= pomDir + nazevPolozky + '.nfo';
// xmlDocTag.WriterSettings.IndentType:=itIndent;
// xmlDocTag.SaveToFile(PomFile);
// end;
// end;
begin
//pomSerieNazev:=''; // nfo soubor se u serie vytváří jenom jednou a to v adresáři serie
ModalResult:=mrOK;
for i:=0 to Form1.dbgrid1.SelectedRows.Count-1 do
begin
Form1.ZQuery1.GotoBookmark(Form1.dbgrid1.SelectedRows.Items[i]);
if Form1.ZQuery1.FieldByName('DRUH').AsString = 'series'
then
begin
LabeledEdit1.Text:=Form1.ZQuery1.FieldByName('NAZEV_SERIALU').AsString;
//if LabeledEdit1.Text <> pomSerieNazev then
// vytvorXMLsTagem('tvshow',LabeledEdit1.Text,'Offline');
end
else
begin
LabeledEdit1.Text:=Form1.ZQuery1.FieldByName('NAZEV').AsString;
//vytvorXMLsTagem('movie', LabeledEdit1.Text +'('+
// Form1.ZQuery1.FieldByName('ROK').AsString + ')',
// 'Offline');
end;
LabeledEdit2.Text:=Form1.ZQuery1.FieldByName('UMISTENI').AsString;
xmlDoc:=CreateXMLDoc('discstub');
discstub:=xmlDoc.DocumentElement;
discstub.AddChild('title').AddText(LabeledEdit1.Text);
discstub.AddChild('message').AddText(LabeledEdit2.Text);
PomS:=DirectoryEdit1.Directory;
PomS:=PomS+Form1.ZQuery1.FieldByName('DIRECTORY').AsString;
If ForceDirectories((PomS)) then //utf8tosys
begin
Poms:=Poms+Form1.ZQuery1.FieldByName('STUBFILE').AsString;
xmlDoc.WriterSettings.IndentType:=itIndent;
xmlDoc.SaveToFile(PomS);
end;
end;
end;
end.