| 1066 | |
| 1067 | |
| 1068 | void GUI::queue_save_data(size_t max_qitems_to_process) |
| 1069 | { |
| 1070 | conf.unfinished_queue_items.clear(); |
| 1071 | unfinished_qitems_data.clear(); |
| 1072 | unsigned unfinished_qitems_with_data {0}; |
| 1073 | for(size_t cat {0}; cat < lbq.size_categ(); cat++) |
| 1074 | { |
| 1075 | auto icat {lbq.at(cat)}; |
| 1076 | if(icat.size()) |
| 1077 | { |
| 1078 | for(auto item : icat) |
| 1079 | { |
| 1080 | auto text {item.text(3)}; |
| 1081 | if(text != "done" && (text != "error" || text == "error" && conf.cb_save_errors)) |
| 1082 | { |
| 1083 | auto &bot {bottoms.at(item.value<lbqval_t>())}; |
| 1084 | if(!bot.vidinfo.empty() || !bot.playlist_info.empty()) |
| 1085 | unfinished_qitems_with_data++; |
| 1086 | } |
| 1087 | } |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | if(unfinished_qitems_with_data <= 50 || max_qitems_to_process != -1) |
| 1092 | { |
| 1093 | size_t qitems_processed {0}; |
| 1094 | for(size_t cat {0}; cat < lbq.size_categ() && qitems_processed < max_qitems_to_process; cat++, qitems_processed++) |
| 1095 | { |
| 1096 | auto icat {lbq.at(cat)}; |
| 1097 | if(icat.size()) |
| 1098 | { |
| 1099 | auto &qitems {conf.unfinished_queue_items.emplace_back(icat.text(), std::vector<std::string>{}).second}; |
| 1100 | for(auto item : icat) |
| 1101 | { |
| 1102 | auto text {item.text(3)}; |
| 1103 | if(text != "done" && (text != "error" || text == "error" && conf.cb_save_errors)) |
| 1104 | { |
| 1105 | const auto wurl {item.value<lbqval_t>().url}; |
| 1106 | const auto url {nana::to_utf8(wurl)}; |
| 1107 | qitems.push_back(url); |
| 1108 | auto &bottom {bottoms.at(url)}; |
| 1109 | if(!bottom.vidinfo.empty() || !bottom.playlist_info.empty()) |
| 1110 | { |
| 1111 | if(max_qitems_to_process == -1 || bottom.playlist_info.empty() || bottom.playlist_info["entries"].size() <= 10) |
| 1112 | { |
| 1113 | auto &j {unfinished_qitems_data[url]}; |
| 1114 | bottom.to_json(j); |
| 1115 | j["columns"]["website"] = item.text(1); |
| 1116 | j["columns"]["status"] = text; |
| 1117 | j["columns"]["format"] = item.text(4); |
| 1118 | j["columns"]["format_note"] = item.text(5); |
| 1119 | j["columns"]["ext"] = item.text(6); |
| 1120 | j["columns"]["fsize"] = item.text(7); |
| 1121 | } |
| 1122 | } |
| 1123 | } |
| 1124 | } |
| 1125 | } |