タイニー番組ナビゲータ本体
リビジョン | 0338c736a3cd733a15dcaa6e305f7efbec5be1a9 (tree) |
---|---|
日時 | 2020-09-19 20:56:43 |
作者 | Masahiko Kimura <mkimura@u01....> |
コミッター | Masahiko Kimura |
Ver.1.12.16 (2020/09/19)
@@ -5,7 +5,7 @@ import java.util.regex.Pattern; | ||
5 | 5 | |
6 | 6 | |
7 | 7 | public class VersionInfo { |
8 | - private static final String Version = "タイニー番組ナビゲータ for DBR-T2007 3.22.18β+1.12.15"; | |
8 | + private static final String Version = "タイニー番組ナビゲータ for DBR-T2007 3.22.18β+1.12.16"; | |
9 | 9 | |
10 | 10 | private static final String OSname = System.getProperty("os.name"); |
11 | 11 | private static final String OSvers = System.getProperty("os.version"); |
@@ -272,8 +272,10 @@ public class PlugIn_TVPDimora extends TVProgramUtils implements TVProgram,Clonea | ||
272 | 272 | try { |
273 | 273 | // |
274 | 274 | String response = null; |
275 | + String prefix = null; | |
275 | 276 | File f = new File(progCacheFile); |
276 | - if (force == true || f.exists() == false || isCacheOld(progCacheFile)){ | |
277 | + boolean bFileAvailable = CommonUtils.isFileAvailable(f,10); | |
278 | + if (force || !f.exists() || !bFileAvailable || isCacheOld(progCacheFile)){ | |
277 | 279 | GregorianCalendar c = new GregorianCalendar(); |
278 | 280 | c.setTime(new Date()); |
279 | 281 |
@@ -308,27 +310,20 @@ public class PlugIn_TVPDimora extends TVProgramUtils implements TVProgram,Clonea | ||
308 | 310 | |
309 | 311 | String targetOnline = "["+dt+"日/"+aname+"]: ("+counter+"/"+counterMax+") "+url+"?"+pstr+"("+areacode+")"; |
310 | 312 | if ( response != null ){ |
311 | - if ( CommonUtils.write2file(progCacheFile, "<!-- "+url+"?"+pstr+" -->\n"+response) ) { | |
312 | - reportProgress(MSGID+"番組表(オンライン)を取得しました" + targetOnline); | |
313 | - } | |
314 | - else{ | |
315 | - reportProgress(ERRID+"番組表(キャッシュ)の保存に失敗しました: "+targetCache); | |
316 | - } | |
317 | - | |
313 | + reportProgress(MSGID+"番組表(オンライン)を取得しました" + targetOnline); | |
314 | + prefix = "<!-- "+url+"?"+pstr+" -->\n"; | |
318 | 315 | setCacheFileOnly(false); |
319 | 316 | } |
320 | 317 | else{ |
321 | 318 | reportProgress(ERRID+"番組表(オンライン)の取得に失敗しました" + targetOnline); |
322 | 319 | if (f.exists() == false) |
323 | 320 | return false; |
324 | - else | |
325 | - reportProgress(MSGID+"番組表(キャッシュ)を代わりに使用します: "+targetCache); | |
321 | + reportProgress(MSGID+"番組表(キャッシュ)を代わりに使用します: "+targetCache); | |
326 | 322 | } |
327 | - | |
328 | 323 | } |
329 | 324 | |
330 | 325 | if (response == null){ |
331 | - if (CommonUtils.isFileAvailable(f,10)) { | |
326 | + if (bFileAvailable) { | |
332 | 327 | // キャッシュファイルの読み込み |
333 | 328 | response = CommonUtils.read4file(progCacheFile, false); |
334 | 329 | if ( response == null ) { |
@@ -348,6 +343,17 @@ public class PlugIn_TVPDimora extends TVProgramUtils implements TVProgram,Clonea | ||
348 | 343 | reportProgress(ERRID+"番組表に有効なエントリがありません"+targetCache); |
349 | 344 | return false; |
350 | 345 | } |
346 | + | |
347 | + if ( prefix != null ){ | |
348 | + if ( CommonUtils.write2file(progCacheFile, prefix+response) ) { | |
349 | + reportProgress(MSGID+"番組表(キャッシュ)に保存しました" + targetCache); | |
350 | + } | |
351 | + else{ | |
352 | + reportProgress(ERRID+"番組表(キャッシュ)の保存に失敗しました: "+targetCache); | |
353 | + } | |
354 | + | |
355 | + setCacheFileOnly(false); | |
356 | + } | |
351 | 357 | } |
352 | 358 | catch (Exception e) { |
353 | 359 | reportProgress(ERRID+"番組表の取得で例外が発生しました: "+e.toString()); |
@@ -372,8 +378,10 @@ public class PlugIn_TVPDimora extends TVProgramUtils implements TVProgram,Clonea | ||
372 | 378 | try { |
373 | 379 | // |
374 | 380 | String response = null; |
381 | + String prefix = null; | |
375 | 382 | File f = new File(progCacheFile); |
376 | - if (force == true || f.exists() == false || isCacheOld(progCacheFile)){ | |
383 | + boolean bFileAvailable = CommonUtils.isFileAvailable(f,10); | |
384 | + if (force || !f.exists() || !bFileAvailable || isCacheOld(progCacheFile)){ | |
377 | 385 | GregorianCalendar c = new GregorianCalendar(); |
378 | 386 | c.setTime(new Date()); |
379 | 387 |
@@ -403,27 +411,22 @@ public class PlugIn_TVPDimora extends TVProgramUtils implements TVProgram,Clonea | ||
403 | 411 | |
404 | 412 | String targetOnline = "["+dt+"日/"+aname+"]: ("+counter+"/"+counterMax+") "+url+"?"+pstr+"("+areacode+")"; |
405 | 413 | if ( response != null ){ |
406 | - if ( CommonUtils.write2file(progCacheFile, "<!-- "+url+"?"+pstr+" -->\n"+response) ) { | |
407 | - reportProgress(MSGID+"番組表(オンライン)を取得しました" + targetOnline); | |
408 | - } | |
409 | - else{ | |
410 | - reportProgress(ERRID+"番組表(キャッシュ)の保存に失敗しました: "+targetCache); | |
411 | - } | |
412 | - | |
414 | + prefix = "<!-- "+url+"?"+pstr+" -->\n"; | |
415 | + reportProgress(MSGID+"番組表(オンライン)を取得しました" + targetOnline); | |
413 | 416 | setCacheFileOnly(false); |
414 | 417 | } |
415 | 418 | else{ |
416 | 419 | reportProgress(ERRID+"番組表(オンライン)の取得に失敗しました" + targetOnline); |
417 | 420 | if (f.exists() == false) |
418 | 421 | return false; |
419 | - else | |
420 | - reportProgress(MSGID+"番組表(キャッシュ)を代わりに使用します: "+targetCache); | |
422 | + | |
423 | + reportProgress(MSGID+"番組表(キャッシュ)を代わりに使用します: "+targetCache); | |
421 | 424 | } |
422 | 425 | |
423 | 426 | } |
424 | 427 | |
425 | 428 | if (response == null){ |
426 | - if (CommonUtils.isFileAvailable(f,10)) { | |
429 | + if (bFileAvailable) { | |
427 | 430 | // キャッシュファイルの読み込み |
428 | 431 | response = CommonUtils.read4file(progCacheFile, false); |
429 | 432 | if ( response == null ) { |
@@ -443,6 +446,15 @@ public class PlugIn_TVPDimora extends TVProgramUtils implements TVProgram,Clonea | ||
443 | 446 | reportProgress(ERRID+"番組表に有効なエントリがありません"+targetCache); |
444 | 447 | return false; |
445 | 448 | } |
449 | + | |
450 | + if (prefix != null){ | |
451 | + if ( CommonUtils.write2file(progCacheFile, prefix+response) ) { | |
452 | + reportProgress(MSGID+"番組表(キャッシュ)に保存しました" + targetCache); | |
453 | + } | |
454 | + else{ | |
455 | + reportProgress(ERRID+"番組表(キャッシュ)の保存に失敗しました: "+targetCache); | |
456 | + } | |
457 | + } | |
446 | 458 | } |
447 | 459 | catch (Exception e) { |
448 | 460 | reportProgress(ERRID+"番組表の取得で例外が発生しました: "+e.toString()); |