-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdateFiles.bas
1249 lines (813 loc) · 40.4 KB
/
updateFiles.bas
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Attribute VB_Name = "updateFiles"
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Dim progressM As Long
Dim FileList() As String
Public stopSignalNet As Boolean
Public moviesNotUpdated As Long
Public totalMovies As Long
Dim imdbArray() As String
Private Type MovieInfo
MovieFileName As String
MovieWatched As String
MovieHash As String
MovieIMDBid As String
MovieTitle As String
MovieYear As String
MovieIMDbRating As String
MovieMyRating As String
MovieLanguage As String
MovieCountry As String
MovieDuration As String
MovieDirector As String
MoviePlot As String
MovieGenre() As String
MovieCoverSmall As String
MovieCoverLarge As String
MovieCast As String
MovieIsFav As String
MovieHashFailed As String
MovieUpdatedOnce As String
MovieLocFolder As String
MovieUnID As String
MovieIcon As StdPicture
MovieSearchRelevance As Integer
movieIdentifier As Long
MovieDisplayFlag As Boolean
isMovie As String
wacthedCategory As Boolean
DateAdded As Date
End Type
Public movieArray() As MovieInfo
Public Function updateFileList(statusObj As Control)
Dim mObj As New ChilkatXml
Dim nObj As New ChilkatXml
Dim i, j
statusObj = "Scanning Started... Please be patient..."
On Error GoTo updateFileList_Error
mObj.LoadXmlFile App.path & "\Data\Loc.xml"
For i = 0 To mObj.NumChildrenHavingTag("Location") - 1
DoEvents
ReDim FileList(0) As String
Set nObj = mObj.GetNthChildWithTag("Location", i)
statusObj = "Scanning " & nObj.Content
If nObj.GetAttrValue("rec") = "Yes" Then
recFolder nObj.Content, statusObj
Else
Dim noRec As New FileSystemObject
Dim noRecF As Folder
Set noRecF = noRec.GetFolder(nObj.Content)
For Each j In noRecF.Files
If LCase(Right(j, 4)) = ".avi" Or LCase(Right(j, 4)) = ".mkv" Or LCase(Right(j, 4)) = ".dat" Or LCase(Right(j, 4)) = ".vob" Or LCase(Right(j, 4)) = ".mpg" Or LCase(Right(j, 5)) = ".mpeg" Or LCase(Right(j, 4)) = ".wmv" Or LCase(Right(j, 4)) = ".mp4" Or LCase(Right(j, 4)) = ".vob" Or LCase(Right(j, 4)) = ".mov" Or LCase(Right(j, 4)) = ".flv" Then
If j.Size > 2000000 Then
FileList(UBound(FileList)) = j
statusObj = str(UBound(FileList)) + " Files Found"
ReDim Preserve FileList(UBound(FileList) + 1) As String
End If
End If
DoEvents
Next
End If
createNewDatabase nObj.Content, FileList, statusObj
DoEvents
Next
On Error GoTo 0
Exit Function
updateFileList_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure updateFileList of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Public Function recFolder(path As String, statusObj As Control)
Dim fCollection As New FileSystemObject
Dim fl As Folder
Dim i, j
On Error GoTo recFolder_Error
Set fl = fCollection.GetFolder(path)
For Each j In fl.Files
If LCase(Right(j, 4)) = ".avi" Or LCase(Right(j, 4)) = ".mkv" Or LCase(Right(j, 4)) = ".dat" Or LCase(Right(j, 4)) = ".vob" Or LCase(Right(j, 4)) = ".mpg" Or LCase(Right(j, 5)) = ".mpeg" Or LCase(Right(j, 4)) = ".wmv" Or LCase(Right(j, 4)) = ".mp4" Or LCase(Right(j, 4)) = ".vob" Or LCase(Right(j, 4)) = ".mov" Or LCase(Right(j, 4)) = ".flv" Then
If j.Size > 2000000 Then
statusObj = str(UBound(FileList)) + " Files Found"
FileList(UBound(FileList)) = j
ReDim Preserve FileList(UBound(FileList) + 1) As String
DoEvents
End If
End If
Next
For Each i In fl.SubFolders
DoEvents
recFolder i.path, statusObj
Next
On Error GoTo 0
Exit Function
recFolder_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure recFolder of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Public Function genUnID()
Dim i, k
Dim str As String
Dim id As String
On Error GoTo genUnID_Error
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
id = ""
For i = 0 To 20
k = Int(Rnd * 10000) Mod 61 + 1
id = id & Mid(str, k, 1)
Next
genUnID = id
On Error GoTo 0
Exit Function
genUnID_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure genUnID of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Public Function createNewDatabase(dir As String, vidList() As String, statusObj As Control)
'the ubound of vidlist has no value
Dim db As New ChilkatXml
Dim dbCh As ChilkatXml
Dim i, strF
Dim uID
Dim prgs As Long, maxPrgs As Long
On Error GoTo createNewDatabase_Error
maxPrgs = UBound(vidList) - LBound(vidList)
Set db = db.NewChild("Movies", "")
For i = LBound(vidList) To UBound(vidList) - 1
Set dbCh = db.NewChild("Movie", "")
dbCh.addAttribute "isMovie", "Yes"
strF = vidList(i)
strF = Right(strF, Len(strF) - Len(dir))
dbCh.NewChild "FileName", strF
dbCh.NewChild "Watched", "No"
dbCh.NewChild "Hash", find_Hash(vidList(i))
dbCh.NewChild "ImdbID", ""
Dim l
l = InStrRev(strF, "\")
dbCh.NewChild "Title", Right(strF, Len(strF) - l)
dbCh.NewChild "Year", ""
dbCh.NewChild "IMDBRating", ""
dbCh.NewChild "MyRating", "0"
dbCh.NewChild "Languages", ""
dbCh.NewChild "Country", ""
dbCh.NewChild "Duration", ""
dbCh.NewChild "Directors", ""
dbCh.NewChild "Plot", ""
dbCh.NewChild "Genres", ""
dbCh.NewChild "CoverSmall", ""
dbCh.NewChild "CoverLarge", ""
dbCh.NewChild "Cast", ""
dbCh.NewChild "HashFailed", "No"
dbCh.NewChild "UpdatedOnce", "No"
dbCh.NewChild "Fav", "No"
dbCh.NewChild "DateAdded", DateTime.Now
Dim yesOrNo, abc, NoMovies
Dim fDbCh As New ChilkatXml
NoMovies = db.NumChildrenHavingTag("Movie")
Repeat: uID = genUnID
yesOrNo = 0
For abc = 0 To NoMovies - 1
Set fDbCh = db.GetNthChildWithTag("Movie", abc)
If uID = fDbCh.GetChildContent("UnID") Then yesOrNo = 1
Next
If yesOrNo = 0 Then
dbCh.NewChild "UnID", uID
Else
GoTo Repeat
End If
prgs = CInt(((i + 1) / maxPrgs) * 100)
statusObj = "Creating Database at Location..." & str(prgs) & " %"
DoEvents
Next
Dim sk As New FileSystemObject
If Not sk.FolderExists(dir & "\MyMovieManager_Data_XYZ") Then sk.CreateFolder (dir & "\MyMovieManager_Data_XYZ")
If sk.FolderExists(dir & "\MyMovieManager_Data_XYZ") Then
Dim mmm As Folder
Set mmm = sk.GetFolder(dir & "\MyMovieManager_Data_XYZ")
mmm.Attributes = Hidden + Directory + System
End If
db.SaveXml dir & "\MyMovieManager_Data_XYZ\data.xml"
On Error GoTo 0
Exit Function
createNewDatabase_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure createNewDatabase of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Public Function find_Hash(path As String) As String
On Error GoTo find_Hash_Error
On Error GoTo ErrM:
Dim fl As Long
Dim fsize As Variant
Dim byteArray(7) As Byte
Dim intArray(7) As Long
Dim Hash As String
Dim i, j
fl = FreeFile()
For j = 0 To 7
intArray(j) = 0
Next
fsize = FileLen(path)
If fsize < 0 Then GoTo ErrM
Open path For Binary As #fl
Seek #fl, 1
For i = 0 To 8191
Get #fl, , byteArray
For j = 0 To 7
intArray(j) = intArray(j) + byteArray(j)
Next
Next
If (fsize - 65536 + 1) > 0 Then
Seek #fl, fsize - 65536 + 1
Else
Seek #fl, 1
End If
For i = 0 To 8191
Get #fl, , byteArray
For j = 0 To 7
intArray(j) = intArray(j) + byteArray(j)
Next
Next
Close #fl
For i = 0 To 7
intArray(i) = intArray(i) + fsize Mod 256
fsize = fsize \ 256
Next
For i = 0 To 6
intArray(i + 1) = intArray(i + 1) + (intArray(i) \ 256)
Next
For i = 0 To 7
byteArray(i) = CByte(intArray(i) Mod 256)
Next
Hash = ""
For i = 7 To 0 Step -1
If Len(Hex(byteArray(i))) < 2 Then
Hash = Hash & "0" & Hex(byteArray(i))
Else
Hash = Hash & Hex(byteArray(i))
End If
Next
Hash = LCase(Hash)
'MsgBox path + vbCrLf + Hash
find_Hash = Hash
Exit Function
ErrM:
find_Hash = 0
'8E245D9679D31E12
On Error GoTo 0
Exit Function
find_Hash_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure find_Hash of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Public Function updateDataBase(delEntry As Boolean, addEntry As Boolean, statusObj As Control)
Dim deletedNo, addNo
Dim mObj As New ChilkatXml
Dim nObj As New ChilkatXml
Dim i, kj, j
Dim noRec As New FileSystemObject
Dim noRecF As Folder
On Error GoTo updateDataBase_Error
If addEntry Then
addNo = 0
mObj.LoadXmlFile App.path & "\Data\Loc.xml"
kj = mObj.NumChildrenHavingTag("Location")
For i = 0 To kj - 1
ReDim FileList(0) As String
Set nObj = mObj.GetNthChildWithTag("Location", i)
If nObj.GetAttrValue("rec") = "Yes" Then
recFolder nObj.Content, statusObj
Else
Set noRecF = noRec.GetFolder(nObj.Content)
Dim fileJ
For Each fileJ In noRecF.Files
If LCase(Right(fileJ, 4)) = ".avi" Or LCase(Right(fileJ, 4)) = ".mkv" Or LCase(Right(fileJ, 4)) = ".dat" Or LCase(Right(fileJ, 4)) = ".vob" Or LCase(Right(fileJ, 4)) = ".mpg" Or LCase(Right(fileJ, 5)) = ".mpeg" Or LCase(Right(fileJ, 4)) = ".wmv" Or LCase(Right(fileJ, 4)) = ".mp4" Or LCase(Right(fileJ, 4)) = ".vob" Or LCase(Right(fileJ, 4)) = ".mov" Or LCase(Right(fileJ, 4)) = ".flv" Then
If fileJ.Size > 2000000 Then
FileList(UBound(FileList)) = fileJ
ReDim Preserve FileList(UBound(FileList) + 1) As String
DoEvents
End If
End If
Next
End If
'''''''''''''''''''''''''''''''''''''''
Dim db As New ChilkatXml
Dim dbCh As New ChilkatXml
Dim fDbCh As New ChilkatXml
Dim uID
Dim strF
Dim NoMovies, abc, yesOrNo
Dim sk As New FileSystemObject
If Not sk.FolderExists(nObj.Content & "\MyMovieManager_Data_XYZ") Then sk.CreateFolder (nObj.Content & "\MyMovieManager_Data_XYZ")
If sk.FolderExists(nObj.Content & "\MyMovieManager_Data_XYZ") Then
Dim mmm As Folder
Set mmm = sk.GetFolder(nObj.Content & "\MyMovieManager_Data_XYZ")
mmm.Attributes = Hidden + Directory + System
End If
''untested code
''''''''''''''''''''''''''''''
If Not sk.FileExists(nObj.Content & "\MyMovieManager_Data_XYZ\data.xml") Then
Set db = db.NewChild("Movies", "")
Else
db.LoadXmlFile nObj.Content & "\MyMovieManager_Data_XYZ\data.xml"
End If
''''''''''''''''''''''''''''''
NoMovies = db.NumChildrenHavingTag("Movie")
For j = LBound(FileList) To UBound(FileList) - 1
DoEvents
strF = FileList(j)
strF = Right(strF, Len(strF) - Len(nObj.Content))
yesOrNo = 0
For abc = 0 To NoMovies - 1
DoEvents
Set fDbCh = db.GetNthChildWithTag("Movie", abc)
If strF = fDbCh.GetChildContent("FileName") Then yesOrNo = 1
Next
If yesOrNo = 0 Then
Dim yesOrNoHash
yesOrNoHash = 0
Dim abcY
Dim mnA As String
mnA = find_Hash(FileList(j))
For abcY = 0 To NoMovies - 1
DoEvents
Set fDbCh = db.GetNthChildWithTag("Movie", abcY)
If mnA = fDbCh.GetChildContent("Hash") And (Not Trim(fDbCh.GetChildContent("Hash")) = "0") And (Not Trim(fDbCh.GetChildContent("Hash")) = "") Then
yesOrNoHash = 1
GoTo sM:
End If
Next
sM:
addNo = addNo + 1
statusObj = str(addNo) & " New Files Added..."
Set dbCh = db.NewChild("Movie", "")
dbCh.addAttribute "isMovie", "Yes"
dbCh.NewChild "FileName", strF
dbCh.NewChild "Watched", "No"
dbCh.NewChild "Hash", find_Hash(FileList(j))
dbCh.NewChild "ImdbID", ""
dbCh.NewChild "Title", ""
dbCh.NewChild "Year", ""
dbCh.NewChild "IMDBRating", ""
dbCh.NewChild "MyRating", "0"
dbCh.NewChild "Languages", ""
dbCh.NewChild "Country", ""
dbCh.NewChild "Duration", ""
dbCh.NewChild "Directors", ""
dbCh.NewChild "Plot", ""
dbCh.NewChild "Genres", ""
dbCh.NewChild "CoverSmall", ""
dbCh.NewChild "CoverLarge", ""
dbCh.NewChild "Cast", ""
dbCh.NewChild "HashFailed", "No"
dbCh.NewChild "UpdatedOnce", "No"
dbCh.NewChild "Fav", "No"
dbCh.NewChild "DateAdded", DateTime.Now
Repeat: uID = genUnID
yesOrNo = 0
For abc = 0 To NoMovies - 1
DoEvents
Set fDbCh = db.GetNthChildWithTag("Movie", abc)
If uID = fDbCh.GetChildContent("UnID") Then yesOrNo = 1
Next
If yesOrNo = 0 Then
dbCh.NewChild "UnID", uID
Else
GoTo Repeat
End If
If yesOrNoHash = 1 Then
Set fDbCh = db.GetNthChildWithTag("Movie", abcY)
dbCh.UpdateAttribute "isMovie", "Yes"
dbCh.UpdateChildContent "ImdbID", fDbCh.GetChildContent("ImdbID")
dbCh.UpdateChildContent "Title", fDbCh.GetChildContent("Title")
dbCh.UpdateChildContent "Year", fDbCh.GetChildContent("Year")
dbCh.UpdateChildContent "IMDBRating", fDbCh.GetChildContent("IMDBRating")
dbCh.UpdateChildContent "MyRating", "0"
dbCh.UpdateChildContent "Languages", fDbCh.GetChildContent("Languages")
dbCh.UpdateChildContent "Country", fDbCh.GetChildContent("Country")
dbCh.UpdateChildContent "Duration", fDbCh.GetChildContent("Duration")
dbCh.UpdateChildContent "Directors", fDbCh.GetChildContent("Directors")
dbCh.UpdateChildContent "Plot", fDbCh.GetChildContent("Plot")
dbCh.UpdateChildContent "Cast", fDbCh.GetChildContent("Cast")
dbCh.UpdateChildContent "HashFailed", "No"
dbCh.UpdateChildContent "UpdatedOnce", "No"
dbCh.UpdateChildContent "Fav", "No"
Dim genCopy As New ChilkatXml
Set genCopy = fDbCh.GetChildWithTag("Genres")
dbCh.removeChild ("Genres")
dbCh.AddChildTree genCopy
Dim imgCopy As New FileSystemObject
If Not fDbCh.GetChildContent("CoverSmall") = "" Then
If imgCopy.FileExists(nObj.Content & "\MyMovieManager_Data_XYZ\Covers\" & fDbCh.GetChildContent("CoverSmall")) Then
imgCopy.CopyFile nObj.Content & "\MyMovieManager_Data_XYZ\Covers\" & fDbCh.GetChildContent("CoverSmall"), nObj.Content & "\MyMovieManager_Data_XYZ\Covers\" & dbCh.GetChildContent("UnID") & ".jpg", True
dbCh.UpdateChildContent "CoverSmall", dbCh.GetChildContent("UnID") & ".jpg"
End If
End If
If Not fDbCh.GetChildContent("CoverLarge") = "" Then
If imgCopy.FileExists(nObj.Content & "\MyMovieManager_Data_XYZ\Covers\" & fDbCh.GetChildContent("CoverLarge")) Then
imgCopy.CopyFile nObj.Content & "\MyMovieManager_Data_XYZ\Covers\" & fDbCh.GetChildContent("CoverLarge"), nObj.Content & "\MyMovieManager_Data_XYZ\Covers\" & dbCh.GetChildContent("UnID") & "_large.jpg", True
dbCh.UpdateChildContent "CoverLarge", dbCh.GetChildContent("UnID") & "_large.jpg"
End If
End If
End If
End If
DoEvents
db.SaveXml nObj.Content & "\MyMovieManager_Data_XYZ\data.xml"
Next
'''''''''''''''''''''''''''''''''''''''
DoEvents
db.SaveXml nObj.Content & "\MyMovieManager_Data_XYZ\data.xml"
Next
End If
If delEntry Then
Dim minus As Long
Dim skF As New FileSystemObject
Dim sDB As New ChilkatXml
Dim sDBc As New ChilkatXml
Dim flNme
deletedNo = 0
minus = 0
mObj.LoadXmlFile App.path & "\Data\Loc.xml"
kj = mObj.NumChildrenHavingTag("Location")
For i = 0 To kj - 1
DoEvents
Dim jk
Set nObj = mObj.GetNthChildWithTag("Location", i)
sDB.LoadXmlFile nObj.Content & "\MyMovieManager_Data_XYZ\data.xml"
For jk = 0 To sDB.NumChildrenHavingTag("Movie") - 1
Set sDBc = sDB.GetNthChildWithTag("Movie", jk - minus)
flNme = nObj.Content & sDBc.GetChildContent("FileName")
If Not skF.FileExists(flNme) Then
sDB.RemoveChildByIndex jk - minus
deletedNo = deletedNo + 1
statusObj = str(deletedNo) & " Old Entries Removed..."
minus = minus + 1
End If
sDB.SaveXml nObj.Content & "\MyMovieManager_Data_XYZ\data.xml"
Next
sDB.SaveXml nObj.Content & "\MyMovieManager_Data_XYZ\data.xml"
Next
End If
On Error GoTo 0
Exit Function
updateDataBase_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure updateDataBase of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Public Function updateFromNet(onlyNew As Boolean, fileStatusObj As Control, statusObj As Control, progressB As ProgressBar, errorControl As Control)
On Error GoTo updateFromNet_Error
If InternetCheckConnection("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "Not Connected to Internet, Please try After Connecting To Internet", vbInformation
Exit Function
End If
If Not moviesNotUpdated = 0 Then
progressB.Max = moviesNotUpdated
Else
progressB.Max = 1
End If
Dim mObj As New ChilkatXml
Dim nObj As New ChilkatXml
Dim i, kj
Dim neT As New ChilkatXml
Dim neTc As New ChilkatXml
Dim iNet As Long
Dim Location
mObj.LoadXmlFile App.path & "\Data\Loc.xml"
progressM = 0
kj = mObj.NumChildrenHavingTag("Location")
For i = 0 To kj - 1
Set nObj = mObj.GetNthChildWithTag("Location", i)
Location = nObj.Content
Dim skC As New FileSystemObject
If Not skC.FolderExists(Location & "\MyMovieManager_Data_XYZ") Then skC.CreateFolder (Location & "\MyMovieManager_Data_XYZ")
If Not skC.FolderExists(Location & "\MyMovieManager_Data_XYZ\Covers") Then skC.CreateFolder (Location & "\MyMovieManager_Data_XYZ\Covers")
If skC.FolderExists(Location & "\MyMovieManager_Data_XYZ") Then
Dim mmmK As Folder
Set mmmK = skC.GetFolder(Location & "\MyMovieManager_Data_XYZ")
mmmK.Attributes = Hidden + Directory + System
End If
neT.LoadXmlFile Location & "\MyMovieManager_Data_XYZ\data.xml"
'MsgBox Location & "\MyMovieManager_Data_XYZ\data.xml" 'neT.NumChildrenHavingTag("Movie") - 1
For iNet = 0 To neT.NumChildrenHavingTag("Movie") - 1
If stopSignalNet = True Then
stopSignalNet = False
GoTo stopUpdating
End If
Set neTc = neT.GetNthChildWithTag("Movie", iNet)
If neTc.GetChildContent("UpdatedOnce") = "Yes" And onlyNew Then
GoTo finish
ElseIf neTc.GetChildContent("HashFailed") = "No" And neTc.GetAttrValue("isMovie") = "Yes" Then
statusObj = "Checking " & Location & neTc.GetChildContent("FileName")
If InternetCheckConnection("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "Not Connected to Internet, Please try After Connecting To Internet", vbInformation
Exit Function
Else
Dim loginData() As String
Dim hashResponse() As String
Dim movieData() As String
loginData = xmlServerActions.loginXml()
DoEvents
If loginData(0) = "200 OK" Then
If Not neTc.GetChildContent("Hash") = "" Then
hashResponse = xmlServerActions.checkMovieHashXml(loginData(3), loginData(1), neTc.GetChildContent("Hash"))
DoEvents
If hashResponse(0) = "200 OK" And (Not hashResponse(1) = "") Then
movieData = xmlServerActions.getIMDBdetailsXml(loginData(3), loginData(1), hashResponse(1))
If movieData(0) = "200 OK" Then
errorControl = ""
neTc.UpdateChildContent "ImdbID", movieData(8)
neTc.UpdateChildContent "Title", movieData(1)
neTc.UpdateChildContent "Year", movieData(2)
neTc.UpdateChildContent "IMDBRating", movieData(3)
neTc.UpdateChildContent "Languages", movieData(4)
neTc.UpdateChildContent "Country", movieData(5)
neTc.UpdateChildContent "Duration", movieData(6)
neTc.UpdateChildContent "Directors", movieData(7)
neTc.UpdateChildContent "Plot", movieData(9)
neTc.removeChild ("Genres")
Dim myGenre As New ChilkatXml
myGenre.loadXML "<Genres>" & movieData(10) & "</Genres>"
neTc.AddChildTree myGenre
'neTc.UpdateChildContent "Genres", movieData(10)
neTc.UpdateChildContent "Cast", movieData(13)
neTc.UpdateChildContent "UpdatedOnce", "Yes"
'MsgBox "here"
If movieData(11) = "" Then
neTc.UpdateChildContent "CoverSmall", ""
neTc.UpdateChildContent "CoverLarge", ""
Else
Dim errcode As Long
Dim urlL As String
Dim localFileName As String
urlL = movieData(11)
localFileName = Location & "\MyMovieManager_Data_XYZ\Covers\" & neTc.GetChildContent("UnID") & ".jpg"
'MsgBox localFileName
errcode = URLDownloadToFile(0, urlL, localFileName, 0, 0)
If errcode = 0 Then
neTc.UpdateChildContent "CoverSmall", neTc.GetChildContent("UnID") & ".jpg"
Else
errorControl = "Error in Connection..."
End If
urlL = movieData(12)
localFileName = Location & "\MyMovieManager_Data_XYZ\Covers\" & neTc.GetChildContent("UnID") & "_large.jpg"
errcode = URLDownloadToFile(0, urlL, localFileName, 0, 0)
If errcode = 0 Then
neTc.UpdateChildContent "CoverLarge", neTc.GetChildContent("UnID") & "_large.jpg"
errorControl = ""
Else
errorControl = "Error in Connection..."
End If
End If
End If
errorControl = ""
Else
errorControl = "Error in Connection..."
End If
End If
errorControl = ""
Else
errorControl = "Error in Connection..."
End If
End If
If Not progressB.Max < progressM Then progressB.Value = progressM
fileStatusObj = str(progressM) & " VideoFiles Checked" & str(moviesNotUpdated - progressM) & " More Video Files to Be Checked."
progressM = progressM + 1
ElseIf Not neTc.GetChildContent("ImdbID") = "" Then
End If
neT.SaveXml Location & "\MyMovieManager_Data_XYZ\data.xml"
'frmMain_Pg.loadAllMovies
finish: DoEvents
Next
neT.SaveXml Location & "\MyMovieManager_Data_XYZ\data.xml"
DoEvents
Next
stopUpdating:
neT.SaveXml Location & "\MyMovieManager_Data_XYZ\data.xml"
DoEvents
fileStatusObj = "Done Updating"
'MsgBox "Done Updating...", vbInformation
progressB.Value = progressB.Max
On Error GoTo 0
Exit Function
updateFromNet_Error:
writeError "Error " & Err.Number & " (" & Err.Description & ") in procedure updateFromNet of Module updateFiles" & vbCrLf & "HelpContext = " & Err.HelpContext & " Source = " & Err.Source
End Function
Function loadAllMovies(statusObj As Control)
Dim savePref As New ChilkatXml
On Error GoTo loadAllMovies_Error
savePref.loadXML App.path & "\Data\Preferences.xml"
totalMovies = savePref.GetChildContent("TotalMovies")
ReDim movieArray(0) As MovieInfo
moviesNotUpdated = 0
ReDim imdbArray(0) As String
Dim locationDB As New ChilkatXml
Dim locationDBCh As New ChilkatXml
Dim movieData As New ChilkatXml
Dim movieDataCh As New ChilkatXml
Dim i, j, l, noLo, noMo
Dim sk As New FileSystemObject
locationDB.LoadXmlFile App.path & "\Data\Loc.xml"
noLo = locationDB.NumChildrenHavingTag("Location")
For i = 0 To noLo - 1
DoEvents
Set locationDBCh = locationDB.GetNthChildWithTag("Location", i)
If sk.FileExists(locationDBCh.Content & "\MyMovieManager_Data_XYZ\data.xml") Then
movieData.LoadXmlFile locationDBCh.Content & "\MyMovieManager_Data_XYZ\data.xml"
'''''''''''''''''''''''''''''Check out follwing line''''''''''''''''''''''''''''
movieData.loadXML htmlDecode(movieData.GetXml)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
noMo = movieData.NumChildrenHavingTag("Movie")
'MsgBox noMo
For j = 0 To noMo - 1
DoEvents
Set movieDataCh = movieData.GetNthChildWithTag("Movie", j)
If (movieDataCh.GetChildContent("UpdatedOnce") = "No" And movieDataCh.GetAttrValue("isMovie") = "Yes") Then moviesNotUpdated = moviesNotUpdated + 1
Dim nIMDBc, imdbPresent
imdbPresent = 0
For nIMDBc = 0 To UBound(imdbArray) - 1
If imdbArray(nIMDBc) = movieDataCh.GetChildContent("ImdbID") And (Not movieDataCh.GetChildContent("ImdbID") = "") Then
imdbPresent = 1
End If
Next
If (Not movieDataCh.GetChildContent("FileName") = "") And movieDataCh.GetAttrValue("isMovie") = "Yes" And imdbPresent = 0 Then
If Not movieDataCh.GetChildContent("Title") = "" Then
movieArray(UBound(movieArray)).MovieTitle = movieDataCh.GetChildContent("Title")
Else
l = InStrRev(movieDataCh.GetChildContent("FileName"), "\")
movieArray(UBound(movieArray)).MovieTitle = Right(movieDataCh.GetChildContent("FileName"), Len(movieDataCh.GetChildContent("FileName")) - l)
End If
imdbArray(UBound(imdbArray)) = movieDataCh.GetChildContent("ImdbID")
ReDim Preserve imdbArray(UBound(imdbArray) + 1) As String
movieArray(UBound(movieArray)).MovieFileName = movieDataCh.GetChildContent("FileName")
movieArray(UBound(movieArray)).MovieWatched = movieDataCh.GetChildContent("Watched")
movieArray(UBound(movieArray)).MovieHash = movieDataCh.GetChildContent("Hash")
movieArray(UBound(movieArray)).MovieIMDBid = movieDataCh.GetChildContent("ImdbID")
movieArray(UBound(movieArray)).MovieYear = movieDataCh.GetChildContent("Year")
movieArray(UBound(movieArray)).MovieIMDbRating = movieDataCh.GetChildContent("IMDBRating")
movieArray(UBound(movieArray)).MovieMyRating = movieDataCh.GetChildContent("MyRating")
movieArray(UBound(movieArray)).MovieLanguage = movieDataCh.GetChildContent("Languages")
movieArray(UBound(movieArray)).MovieCountry = movieDataCh.GetChildContent("Country")
movieArray(UBound(movieArray)).MovieDuration = movieDataCh.GetChildContent("Duration")
movieArray(UBound(movieArray)).MovieDirector = movieDataCh.GetChildContent("Directors")
movieArray(UBound(movieArray)).MoviePlot = movieDataCh.GetChildContent("Plot")
movieArray(UBound(movieArray)).MovieIsFav = movieDataCh.GetChildContent("Fav")
movieArray(UBound(movieArray)).DateAdded = CDate(movieDataCh.GetChildContent("DateAdded"))
Dim skMine As New ChilkatXml
Set skMine = movieDataCh.GetChildWithTag("Genres")
Dim igen, genStr
ReDim movieArray(UBound(movieArray)).MovieGenre(0 To skMine.NumChildrenHavingTag("value")) As String
For igen = 0 To skMine.NumChildrenHavingTag("value") - 1
Set skMine = skMine.GetNthChildWithTag("value", igen)
genStr = skMine.Content
movieArray(UBound(movieArray)).MovieGenre(igen) = genStr
Set skMine = skMine.getParent