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
|
# File 'lib/ZMediumFetcher.rb', line 288
def downloadPostsByUsername(username, pathPolicy)
progress.username = username
progress.message = "Fetching infromation..."
progress.printLog()
userID = User.convertToUserIDFromUsername(username)
if userID.nil?
raise "Medium's Username:#{username} not found!"
end
progress.message = "Fetching posts..."
progress.printLog()
postURLS = []
nextID = nil
begin
postPageInfo = User.fetchUserPosts(userID, nextID)
postPageInfo["postURLs"].each do |postURL|
postURLS.append(postURL)
end
nextID = postPageInfo["nextID"]
end while !nextID.nil?
@usersPostURLs = postURLS
progress.totalPostsLength = postURLS.length
progress.currentPostIndex = 0
progress.message = "Downloading posts..."
progress.printLog()
if isForJekyll
downloadPathPolicy = pathPolicy
else
downloadPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath("users/#{username}"), pathPolicy.getRelativePath("users/#{username}"))
end
index = 0
postURLS.each do |postURL|
downloadPost(postURL, downloadPathPolicy)
index += 1
progress.currentPostIndex = index
progress.message = "Downloading posts..."
progress.printLog()
end
progress.message = "All posts has been downloaded!, Total posts: #{postURLS.length}"
progress.printLog()
end
|