(site_id, just_test)
| 2478 | } |
| 2479 | |
| 2480 | function get_crawler(site_id, just_test) { |
| 2481 | site_id = site_id || site_used; |
| 2482 | // gettext_config:{"id":"please-specify-site-to-download-first"} |
| 2483 | var attention_message = '請先指定要下載的網站。'; |
| 2484 | if (!site_id) { |
| 2485 | if (!just_test) { |
| 2486 | show_attention({ |
| 2487 | b : { |
| 2488 | T : attention_message |
| 2489 | } |
| 2490 | }, attention_message); |
| 2491 | } |
| 2492 | return; |
| 2493 | } |
| 2494 | hide_attention_panel(attention_message); |
| 2495 | |
| 2496 | var crawler = base_directory + site_id + '.js'; |
| 2497 | CeL.debug({ |
| 2498 | // gettext_config:{"id":"current-path-$1"} |
| 2499 | T : [ '當前路徑:%1', CeL.storage.working_directory() ] |
| 2500 | }, 1, 'get_crawler'); |
| 2501 | CeL.debug({ |
| 2502 | // gettext_config:{"id":"load-and-use-the-download-tool-$1"} |
| 2503 | T : [ '載入並使用下載工具 %1', crawler ] |
| 2504 | }, 1, 'get_crawler'); |
| 2505 | |
| 2506 | var old_site_used = site_used; |
| 2507 | // Will used in function prepare_crawler() |
| 2508 | site_used = site_id; |
| 2509 | |
| 2510 | // include site script .js |
| 2511 | // 這個過程會執行 setup_crawler() @ work_crawler_loader.js |
| 2512 | // 以及 setup_crawler.prepare() |
| 2513 | crawler = require(crawler); |
| 2514 | crawler_loaded[site_id] = crawler; |
| 2515 | if (old_site_used !== site_used) { |
| 2516 | // recover |
| 2517 | site_used = old_site_used; |
| 2518 | } else { |
| 2519 | CeL.toggle_display('favorites_panel', true); |
| 2520 | CeL.toggle_display('download_options_panel', true); |
| 2521 | set_panel_height('favorites_panel'); |
| 2522 | // gettext_config:{"id":"select-download-tool-$1"} |
| 2523 | process.title = _('選擇下載工具:%1', crawler.site_id); |
| 2524 | } |
| 2525 | |
| 2526 | // assert: (site_id in download_site_nodes.link_of_site) |
| 2527 | |
| 2528 | return crawler; |
| 2529 | } |
| 2530 | |
| 2531 | // 一個 {Download_job} 只會配上一個作品。不同作品會用到不同的 {Download_job}。 |
| 2532 | function Download_job(crawler, work_id) { |
no test coverage detected