-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add video files to filtering system
…because I need it.
- Loading branch information
Showing
6 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Shoko.Server.Filters.Interfaces; | ||
|
||
namespace Shoko.Server.Filters.Info; | ||
|
||
public class HasVideoFilesExpression : FilterExpression<bool> | ||
{ | ||
public override bool TimeDependent => false; | ||
public override bool UserDependent => false; | ||
public override string HelpDescription => "This condition passes if any of the anime have any video files locally."; | ||
|
||
public override bool Evaluate(IFilterable filterable, IFilterableUserInfo userInfo) | ||
{ | ||
return filterable.VideoFiles > 0; | ||
} | ||
|
||
protected bool Equals(HasVideoFilesExpression other) | ||
{ | ||
return base.Equals(other); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, obj)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (obj.GetType() != this.GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((HasVideoFilesExpression)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return GetType().FullName!.GetHashCode(); | ||
} | ||
|
||
public static bool operator ==(HasVideoFilesExpression left, HasVideoFilesExpression right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(HasVideoFilesExpression left, HasVideoFilesExpression right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Shoko.Server/Filters/Selectors/NumberSelectors/VideoFilesSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Shoko.Server.Filters.Interfaces; | ||
|
||
namespace Shoko.Server.Filters.Selectors.NumberSelectors; | ||
|
||
public class VideoFilesSelector : FilterExpression<double> | ||
{ | ||
public override bool TimeDependent => false; | ||
public override bool UserDependent => false; | ||
public override string HelpDescription => "This returns the number of video files for the filterable."; | ||
public override FilterExpressionGroup Group => FilterExpressionGroup.Selector; | ||
|
||
public override double Evaluate(IFilterable filterable, IFilterableUserInfo userInfo) | ||
{ | ||
return filterable.VideoFiles; | ||
} | ||
|
||
protected bool Equals(VideoFilesSelector other) | ||
{ | ||
return base.Equals(other); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, obj)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (obj.GetType() != this.GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((VideoFilesSelector)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return GetType().FullName!.GetHashCode(); | ||
} | ||
|
||
public static bool operator ==(VideoFilesSelector left, VideoFilesSelector right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(VideoFilesSelector left, VideoFilesSelector right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters