@@ -83,7 +83,7 @@ var fourChanService = {
83
83
84
84
var resources = results . resources ;
85
85
console . log ( 'There going to be downloaded ' + resources . length + ' resources.' ) ;
86
- for ( var cont = 0 ; cont < resources . length ; cont ++ )
86
+ for ( var cont = 0 ; cont < resources . length && cont < 50 ; cont ++ )
87
87
{
88
88
var url = 'http:' + resources [ cont ] ;
89
89
@@ -100,6 +100,63 @@ var fourChanService = {
100
100
console . log ( fileCounter + '::File ' + path + ' downloaded' ) ;
101
101
} ) ;
102
102
}
103
+
104
+ setTimeout ( function ( ) { console . log ( 'Second batch...' ) } , 2000 ) ;
105
+ for ( ; cont < resources . length && cont < 100 ; cont ++ )
106
+ {
107
+ url = 'http:' + resources [ cont ] ;
108
+
109
+ // We set the name for file
110
+ filename = resources [ cont ] . split ( '/' ) ;
111
+ filename = filename [ filename . length - 1 ] ;
112
+
113
+ // We set the full path '.files/boardName/semanticURL/filename'
114
+ path = './files/' + boardName + '/' + surl + '/' + filename ;
115
+
116
+ // We download the file
117
+ fileCounter = cont + 1 ;
118
+ self . dowloadResource ( url , boardName , surl , path , function ( ) {
119
+ console . log ( fileCounter + '::File ' + path + ' downloaded' ) ;
120
+ } ) ;
121
+ }
122
+
123
+ setTimeout ( function ( ) { console . log ( 'Third batch...' ) } , 2000 ) ;
124
+ for ( ; cont < resources . length && cont < 150 ; cont ++ )
125
+ {
126
+ url = 'http:' + resources [ cont ] ;
127
+
128
+ // We set the name for file
129
+ filename = resources [ cont ] . split ( '/' ) ;
130
+ filename = filename [ filename . length - 1 ] ;
131
+
132
+ // We set the full path '.files/boardName/semanticURL/filename'
133
+ path = './files/' + boardName + '/' + surl + '/' + filename ;
134
+
135
+ // We download the file
136
+ fileCounter = cont + 1 ;
137
+ self . dowloadResource ( url , boardName , surl , path , function ( ) {
138
+ console . log ( fileCounter + '::File ' + path + ' downloaded' ) ;
139
+ } ) ;
140
+ }
141
+
142
+ setTimeout ( function ( ) { console . log ( 'Forth batch...' ) } , 2000 ) ;
143
+ for ( ; cont < resources . length && cont < 200 ; cont ++ )
144
+ {
145
+ url = 'http:' + resources [ cont ] ;
146
+
147
+ // We set the name for file
148
+ filename = resources [ cont ] . split ( '/' ) ;
149
+ filename = filename [ filename . length - 1 ] ;
150
+
151
+ // We set the full path '.files/boardName/semanticURL/filename'
152
+ path = './files/' + boardName + '/' + surl + '/' + filename ;
153
+
154
+ // We download the file
155
+ fileCounter = cont + 1 ;
156
+ self . dowloadResource ( url , boardName , surl , path , function ( ) {
157
+ console . log ( fileCounter + '::File ' + path + ' downloaded' ) ;
158
+ } ) ;
159
+ }
103
160
// After all, we call the callback
104
161
callback ( resources ) ;
105
162
} ) ;
@@ -132,7 +189,7 @@ var fourChanService = {
132
189
if ( ! fs . existsSync ( filename ) )
133
190
{
134
191
// We download the file
135
- console . log ( '=== Dowloading::' + uri ) ;
192
+ // console.log('=== Dowloading::' + uri );
136
193
/*request.head(uri, function(err, res, body) {
137
194
// console.log('content-type:', res.headers['content-type']);
138
195
// console.log('content-length:', res.headers['content-length']);
@@ -146,7 +203,15 @@ var fourChanService = {
146
203
} )
147
204
. on ( 'error' , function ( err ) {
148
205
console . log ( err )
149
- } ) ;
206
+ } )
207
+ . on ( 'response' , function ( response ) {
208
+ // unmodified http.IncomingMessage object
209
+ response . on ( 'data' , function ( data ) {
210
+ // compressed data as it is received
211
+ console . log ( 'Received ' + data . length + ' bytes of compressed data' )
212
+ } ) ;
213
+ } ) ;
214
+
150
215
151
216
}
152
217
0 commit comments