Skip to content

Commit badaee6

Browse files
committed
Fix storage time in server list
1 parent e0e2fe3 commit badaee6

File tree

5 files changed

+133
-30
lines changed

5 files changed

+133
-30
lines changed

Data/servers.xml

Lines changed: 108 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<Server Name="ImageBan.ru" Types="image video" Authorize="2" Plugin="imageban" WebsiteUrl="https://imageban.ru" RegistrationUrl="https://imageban.ru/u/register">
2525
<Info>
2626
<SupportedFormats>
27-
<FormatGroup MaxFileSize="10485760" UserTypes="anon, reg">
27+
<FormatGroup MaxFileSize="10485760" UserTypes="anon,reg">
2828
<Format MimeType="image/bmp">*.bmp</Format>
2929
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
3030
<Format MimeType="image/png">*.png</Format>
@@ -508,19 +508,6 @@
508508
<Server Name="mega.nz" Authorize="2" Engine="MegaNz" FileHost="1" SupportsFolders="1" RegistrationUrl="https://mega.nz/register"
509509
WebsiteUrl="https://mega.io/" MaxThreads="1" LoginLabel="Email">
510510
<Info>
511-
<SupportedFormats>
512-
<FormatGroup MaxFileSize="33554432" UserTypes="anon">
513-
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
514-
<Format MimeType="image/png">*.png</Format>
515-
<Format MimeType="image/bmp">*.bmp</Format>
516-
<Format MimeType="image/gif">*.gif</Format>
517-
<Format MimeType="image/tiff">*.tif,*.tiff</Format>
518-
<Format MimeType="image/webp">*.webp</Format>
519-
<Format MimeType="image/heic">*.heic</Format>
520-
<Format MimeType="image/avif">*.avif</Format>
521-
<Format MimeType="application/pdf">*.pdf</Format>
522-
</FormatGroup>
523-
</SupportedFormats>
524511
<StorageTimeInfo>
525512
<StorageTime>-1</StorageTime>
526513
</StorageTimeInfo>
@@ -537,7 +524,19 @@
537524
<Server Name="imgbb.com" MaxFileSize="33554432" Plugin="imgbb" Authorize="1" PasswordLabel="API key" WebsiteUrl="https://imgbb.com/"
538525
RegistrationUrl="https://imgbb.com/signup">
539526
<Info>
540-
527+
<SupportedFormats>
528+
<FormatGroup MaxFileSize="33554432" UserTypes="anon">
529+
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
530+
<Format MimeType="image/png">*.png</Format>
531+
<Format MimeType="image/bmp">*.bmp</Format>
532+
<Format MimeType="image/gif">*.gif</Format>
533+
<Format MimeType="image/tiff">*.tif,*.tiff</Format>
534+
<Format MimeType="image/webp">*.webp</Format>
535+
<Format MimeType="image/heic">*.heic</Format>
536+
<Format MimeType="image/avif">*.avif</Format>
537+
<Format MimeType="application/pdf">*.pdf</Format>
538+
</FormatGroup>
539+
</SupportedFormats>
541540
<StorageTimeInfo>
542541
<StorageTime>-1</StorageTime>
543542
</StorageTimeInfo>
@@ -555,6 +554,9 @@
555554
<Format MimeType="image/gif">*.gif</Format>
556555
</FormatGroup>
557556
</SupportedFormats>
557+
<StorageTimeInfo>
558+
<StorageTime>-1</StorageTime>
559+
</StorageTimeInfo>
558560
</Info>
559561
<Actions>
560562
</Actions>
@@ -565,17 +567,40 @@
565567
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub"/>
566568
</Server>
567569
<Server Name="2i.cz" Authorize="0" Type="image" Plugin="2i" WebsiteUrl="https://2i.cz" RegistrationUrl="https://2i.cz/signup">
570+
<Info>
571+
<SupportedFormats>
572+
<FormatGroup MaxFileSize="20971520">
573+
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
574+
<Format MimeType="image/png">*.png</Format>
575+
<Format MimeType="image/bmp">*.bmp</Format>
576+
<Format MimeType="image/gif">*.gif</Format>
577+
<Format MimeType="image/webp">*.webp</Format>
578+
</FormatGroup>
579+
</SupportedFormats>
580+
<StorageTimeInfo>
581+
<StorageTime>-1</StorageTime>
582+
</StorageTimeInfo>
583+
</Info>
568584
<Actions>
569585
</Actions>
570586
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub"/>
571587
</Server>
572588
<Server Name="vgy.me" Type="image" Authorize="2" Plugin="vgy_me" PasswordLabel="User key" WebsiteUrl="https://vgy.me"
573589
RegistrationUrl="https://vgy.me/auth/register">
590+
<Info>
591+
<SupportedFormats>
592+
<FormatGroup MaxFileSize="20971520">
593+
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
594+
<Format MimeType="image/png">*.png</Format>
595+
<Format MimeType="image/gif">*.gif</Format>
596+
</FormatGroup>
597+
</SupportedFormats>
598+
</Info>
574599
<Actions>
575600
</Actions>
576601
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub"/>
577602
</Server>
578-
<Server Name="yourfilestore.com" FileHost="1" MaxFileSize="500000000" WebsiteUrl="https://yourfilestore.com" MaxThreads="1">
603+
<Server Name="yourfilestore.com" FileHost="1" MaxFileSize="524288000" WebsiteUrl="https://yourfilestore.com" MaxThreads="1">
579604
<Actions>
580605
<Action Type="get" Url="https://yourfilestore.com/" RegExp="UPLOAD_IDENTIFIER&quot;\s+value=&quot;(.+?)&quot;" AssignVars="UploadId:0;">
581606
<RegExp Pattern="xcsrf_token&quot; value=&quot;(.+?)&quot;" AssignVars="XcsrfToken:0"/>
@@ -588,6 +613,24 @@
588613
<Result DownloadUrlTemplate="$(FileId)" DeleteUrl="$(DeleteUrl)"/>
589614
</Server>
590615
<Server Name="freeimage.host" MaxFileSize="67108864" Authorize="0" Type="image" Plugin="freeimage.host" WebsiteUrl="https://freeimage.host/">
616+
<Info>
617+
<SupportedFormats>
618+
<FormatGroup MaxFileSize="67108864" UserTypes="anon">
619+
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
620+
<Format MimeType="image/png">*.png</Format>
621+
<Format MimeType="image/bmp">*.bmp</Format>
622+
<Format MimeType="image/gif">*.gif</Format>
623+
<Format MimeType="image/webp">*.webp</Format>
624+
</FormatGroup>
625+
<FormatGroup MaxFileSize="134217728" UserTypes="reg">
626+
<Format MimeType="image/jpeg">*.jpg,*.jpeg</Format>
627+
<Format MimeType="image/png">*.png</Format>
628+
<Format MimeType="image/bmp">*.bmp</Format>
629+
<Format MimeType="image/gif">*.gif</Format>
630+
<Format MimeType="image/webp">*.webp</Format>
631+
</FormatGroup>
632+
</SupportedFormats>
633+
</Info>
591634
<Actions>
592635
</Actions>
593636
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub"/>
@@ -607,12 +650,28 @@
607650
<Result DownloadUrlTemplate="stub" ThumbUrlTemplate="stub"/>
608651
</Server>
609652
<Server Name="mediafire.com" Authorize="2" FileHost="1" Plugin="mediafire" SupportsFolders="1" MinVersion="1.4.0" WebsiteUrl="https://www.mediafire.com">
653+
<Info>
654+
<SupportedFormats>
655+
<FormatGroup MaxFileSize="4294967296" UserTypes="anon,reg">
656+
<Format>*</Format>
657+
</FormatGroup>
658+
<FormatGroup MaxFileSize="53687091200" UserTypes="pro,business">
659+
<Format>*</Format>
660+
</FormatGroup>
661+
</SupportedFormats>
662+
</Info>
610663
<Actions>
611664
</Actions>
612665
<Result DownloadUrlTemplate="stub" />
613666
</Server>
614667
<Server Name="upload.ee" Authorize="0" FileHost="1" Plugin="upload.ee" MaxFileSize="104857600" WebsiteUrl="https://www.upload.ee"
615668
RegistrationUrl="https://www.upload.ee/register.html">
669+
<Info>
670+
<StorageTimeInfo>
671+
<StorageTime UserTypes="anon" AfterLastDownload="1">50</StorageTime>
672+
<StorageTime UserTypes="reg" AfterLastDownload="1">120</StorageTime>
673+
</StorageTimeInfo>
674+
</Info>
616675
<Actions>
617676
</Actions>
618677
<Result DownloadUrlTemplate="stub" ImageUrlTemplate="stub" ThumbUrlTemplate="stub" />
@@ -630,11 +689,44 @@
630689
</Server>
631690
<Server Name="pixeldrain.com" Authorize="2" FileHost="1" Plugin="pixeldrain.com" NeedPassword="0" WebsiteUrl="https://pixeldrain.com"
632691
RegistrationUrl="https://pixeldrain.com/register">
692+
<Info>
693+
<SupportedFormats>
694+
<FormatGroup MaxFileSize="21474836480" UserTypes="anon,reg">
695+
<Format>*</Format>
696+
</FormatGroup>
697+
<FormatGroup MaxFileSize="107374182400" UserTypes="pro">
698+
<Format>*</Format>
699+
</FormatGroup>
700+
<FormatGroup MaxFileSize="107374182400" UserTypes="prepaid">
701+
<Format>*</Format>
702+
</FormatGroup>
703+
</SupportedFormats>
704+
<StorageTimeInfo>
705+
<StorageTime UserTypes="anon,reg" AfterLastDownload="1">120</StorageTime>
706+
<StorageTime UserTypes="pro" AfterLastDownload="1">240</StorageTime>
707+
<StorageTime UserTypes="prepaid">-1</StorageTime>
708+
</StorageTimeInfo>
709+
</Info>
633710
<Actions>
634711
</Actions>
635712
<Result ThumbUrlTemplate="stub" DownloadUrlTemplate="stub"/>
636713
</Server>
637714
<Server Name="wdfiles.ru" FileHost="1" Plugin="wdfiles" WebsiteUrl="https://wdfiles.ru" RegistrationUrl="https://wdfiles.ru/register.html">
715+
<Info>
716+
<SupportedFormats>
717+
<FormatGroup MaxFileSize="6442450944" UserTypes="anon,reg">
718+
<Format>*</Format>
719+
</FormatGroup>
720+
<FormatGroup MaxFileSize="10737418240" UserTypes="premium">
721+
<Format>*</Format>
722+
</FormatGroup>
723+
</SupportedFormats>
724+
<StorageTimeInfo>
725+
<StorageTime UserTypes="anon" AfterLastDownload="1">120</StorageTime>
726+
<StorageTime UserTypes="reg" AfterLastDownload="1">240</StorageTime>
727+
<StorageTime UserTypes="premium">-1</StorageTime>
728+
</StorageTimeInfo>
729+
</Info>
638730
<Actions>
639731
</Actions>
640732
<Result DownloadUrlTemplate="stub"/>

Data/servers.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<xs:complexType>
122122
<xs:simpleContent>
123123
<xs:extension base="xs:integer">
124-
<xs:attribute type="xs:integer" name="MaxFileSize" use="optional"/>
124+
<xs:attribute type="Bool" name="AfterLastDownload" use="optional"/>
125125
<xs:attribute type="xs:string" name="UserTypes" use="optional"/>
126126
</xs:extension>
127127
</xs:simpleContent>

Source/Core/Upload/UploadEngine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ struct FileFormatGroup {
145145
struct StorageTime {
146146
inline static constexpr int TIME_INFINITE = -1;
147147
int Time = 0; // in days
148+
bool AfterLastDownload = false;
148149
std::vector<std::string> UserTypes;
149150
int MinUserRank = 0;
150151
};
@@ -227,7 +228,7 @@ class CUploadEngineData
227228
std::vector<UploadAction> Actions;
228229
std::vector<FileFormatGroup> SupportedFormatGroups;
229230
std::vector<FileFormatGroup> ForbiddenFormatGroups;
230-
std::vector<StorageTime> StorageTime;
231+
std::vector<StorageTime> StorageTimeInfo;
231232
std::string LoginLabel, PasswordLabel;
232233
std::string UserAgent;
233234
std::string Engine;

Source/Core/UploadEngineList.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ bool CUploadEngineList::loadFromFile(const std::string& filename, ServerSettings
182182

183183
SimpleXmlNode storageTimeInfoNode = infoNode.GetChild("StorageTimeInfo", false);
184184
if (!storageTimeInfoNode.IsNull()) {
185-
loadStorageTimeInfo(storageTimeInfoNode, UE, UE.StorageTime);
185+
loadStorageTimeInfo(storageTimeInfoNode, UE, UE.StorageTimeInfo);
186186
}
187187
}
188188

@@ -358,6 +358,7 @@ void CUploadEngineList::loadStorageTimeInfo(SimpleXmlNode& node, CUploadEngineDa
358358
} catch (const std::exception& ex) {
359359
LOG(WARNING) << "loadStorageTimeInfo exception, line no. " << groupNode.GetLineNumber() << ": " << ex.what();
360360
}
361+
group.AfterLastDownload = groupNode.AttributeBool("AfterLastDownload");
361362

362363
out.push_back(std::move(group));
363364
}

Source/Gui/Models/ServerListModel.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,26 +213,35 @@ bool ServerData::acceptFilter(const ServerFilter& filter) const {
213213
void ServerData::cacheStorageTime() const {
214214
if (!storageTimeStr.has_value()) {
215215
std::string daysStr;
216-
217-
if (ued->StorageTime.size() == 1) {
218-
const auto& item = ued->StorageTime[0];
216+
std::string result;
217+
if (ued->StorageTimeInfo.size() == 1) {
218+
const auto& item = ued->StorageTimeInfo[0];
219219
storageTime = item.Time;
220-
storageTimeStr = item.Time == StorageTime::TIME_INFINITE ? u8"\u221E" : str(IuStringUtils::FormatNoExcept(_n("%d day", "%d days", item.Time)) % item.Time);
221-
} else if (!ued->StorageTime.empty()) {
222-
storageTime = ued->StorageTime[0].Time;
223-
for (const auto& storageTime : ued->StorageTime) {
220+
result = item.Time == StorageTime::TIME_INFINITE ? u8"\u221E" : str(IuStringUtils::FormatNoExcept(_n("%d day", "%d days", item.Time)) % item.Time);
221+
if (item.AfterLastDownload) {
222+
result += u8"\u2913";
223+
}
224+
} else if (!ued->StorageTimeInfo.empty()) {
225+
for (const auto& item : ued->StorageTimeInfo) {
224226
if (!daysStr.empty()) {
225227
daysStr += "/ ";
226228
}
227-
if (storageTime.Time) {
228-
daysStr += storageTime.Time == StorageTime::TIME_INFINITE ? u8"\u221E" : std::to_string(storageTime.Time);
229+
if (item.Time) {
230+
daysStr += item.Time == StorageTime::TIME_INFINITE ? u8"\u221E" : std::to_string(item.Time);
231+
if (item.AfterLastDownload) {
232+
daysStr += u8"\u2913";
233+
}
234+
} else {
235+
daysStr += "?";
229236
}
237+
230238
daysStr += " ";
231239
}
232-
storageTimeStr = daysStr.empty() ? "" : str(IuStringUtils::FormatNoExcept(_("%1%days")) % daysStr);
240+
storageTime = ued->StorageTimeInfo[0].Time;
241+
result = daysStr.empty() ? "" : str(IuStringUtils::FormatNoExcept(_("%1%days")) % daysStr);
233242
} else {
234243
storageTime = 0;
235-
storageTimeStr = "";
236244
}
245+
storageTimeStr = result;
237246
}
238247
}

0 commit comments

Comments
 (0)