🕵🏼♀️ TPB, Mini-series, GN detection WIP
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
|||||||
getComicBookDetailById,
|
getComicBookDetailById,
|
||||||
extractComicArchive,
|
extractComicArchive,
|
||||||
} from "../actions/comicinfo.actions";
|
} from "../actions/comicinfo.actions";
|
||||||
import { detectTradePaperbacks } from "../shared/utils/tradepaperback.utils";
|
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
const prettyBytes = require("pretty-bytes");
|
const prettyBytes = require("pretty-bytes");
|
||||||
import { DnD } from "./DnD";
|
import { DnD } from "./DnD";
|
||||||
@@ -398,8 +398,8 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
|
|||||||
<dd>{props.data.number}</dd>
|
<dd>{props.data.number}</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<div className="field is-grouped is-grouped-multiline">
|
<div className="field is-grouped is-grouped-multiline">
|
||||||
{!isEmpty(
|
{!isUndefined(
|
||||||
detectTradePaperbacks(
|
detectIssueTypes(
|
||||||
comicBookDetailData.sourcedMetadata.comicvine.volumeInformation
|
comicBookDetailData.sourcedMetadata.comicvine.volumeInformation
|
||||||
.description,
|
.description,
|
||||||
),
|
),
|
||||||
@@ -407,7 +407,14 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
|
|||||||
<div className="control">
|
<div className="control">
|
||||||
<div className="tags has-addons">
|
<div className="tags has-addons">
|
||||||
<span className="tag is-light">Detected Type</span>
|
<span className="tag is-light">Detected Type</span>
|
||||||
<span className="tag is-warning">Trade Paperback</span>
|
<span className="tag is-warning">
|
||||||
|
{
|
||||||
|
detectIssueTypes(
|
||||||
|
comicBookDetailData.sourcedMetadata.comicvine
|
||||||
|
.volumeInformation.description,
|
||||||
|
).displayName
|
||||||
|
}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { getComicBooks } from "../actions/fileops.actions";
|
|||||||
import { isNil, isEmpty } from "lodash";
|
import { isNil, isEmpty } from "lodash";
|
||||||
import Masonry from "react-masonry-css";
|
import Masonry from "react-masonry-css";
|
||||||
import Card from "./Carda";
|
import Card from "./Carda";
|
||||||
import { detectTradePaperbacks } from "../shared/utils/tradepaperback.utils";
|
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
interface ILibraryGridProps {}
|
interface ILibraryGridProps {}
|
||||||
@@ -81,7 +81,7 @@ export const LibraryGrid = (libraryGridProps: ILibraryGridProps) => {
|
|||||||
)}
|
)}
|
||||||
{!isNil(sourcedMetadata.comicvine) &&
|
{!isNil(sourcedMetadata.comicvine) &&
|
||||||
!isEmpty(
|
!isEmpty(
|
||||||
detectTradePaperbacks(
|
detectIssueTypes(
|
||||||
sourcedMetadata.comicvine.volumeInformation.description,
|
sourcedMetadata.comicvine.volumeInformation.description,
|
||||||
),
|
),
|
||||||
) ? (
|
) ? (
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
removeLeadingPeriod,
|
removeLeadingPeriod,
|
||||||
escapePoundSymbol,
|
escapePoundSymbol,
|
||||||
} from "../shared/utils/formatting.utils";
|
} from "../shared/utils/formatting.utils";
|
||||||
import { isEmpty, isNil, map } from "lodash";
|
import { isNil, isUndefined, map } from "lodash";
|
||||||
import { detectTradePaperbacks } from "../shared/utils/tradepaperback.utils";
|
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
|
||||||
import Masonry from "react-masonry-css";
|
import Masonry from "react-masonry-css";
|
||||||
|
|
||||||
type RecentlyImportedProps = {
|
type RecentlyImportedProps = {
|
||||||
@@ -71,13 +71,20 @@ export const RecentlyImported = ({
|
|||||||
<i className="fas fa-adjust" />
|
<i className="fas fa-adjust" />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{!isNil(sourcedMetadata.comicvine) &&
|
{!isUndefined(sourcedMetadata.comicvine) &&
|
||||||
!isEmpty(
|
!isNil(
|
||||||
detectTradePaperbacks(
|
detectIssueTypes(
|
||||||
sourcedMetadata.comicvine.volumeInformation.description,
|
sourcedMetadata.comicvine.volumeInformation.description,
|
||||||
),
|
),
|
||||||
) ? (
|
) ? (
|
||||||
<span className="tag is-warning">TPB</span>
|
<span className="tag is-warning">
|
||||||
|
{
|
||||||
|
detectIssueTypes(
|
||||||
|
sourcedMetadata.comicvine.volumeInformation
|
||||||
|
.description,
|
||||||
|
).displayName
|
||||||
|
}
|
||||||
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -1,13 +1,29 @@
|
|||||||
import { compact } from "lodash";
|
import { flatten, compact, map, isEmpty } from "lodash";
|
||||||
|
|
||||||
export const detectTradePaperbacks = (deck): any => {
|
export const detectIssueTypes = (deck: string): any => {
|
||||||
const paperback = [
|
const issueTypeMatchers = [
|
||||||
/((trade)?\s?(paperback)|(tpb))/gim, // https://regex101.com/r/FhuowT/1
|
{
|
||||||
/(hard\s?cover)\s?(collect((ion)|(ed)|(ing)))/gim, //https://regex101.com/r/eFJVRM/1
|
regex: [
|
||||||
|
/((trade)?\s?(paperback)|(tpb))/gim, // https://regex101.com/r/FhuowT/1
|
||||||
|
/(hard\s?cover)\s?(collect((ion)|(ed)|(ing)))/gim, //https://regex101.com/r/eFJVRM/1
|
||||||
|
],
|
||||||
|
displayName: "Trade Paperback",
|
||||||
|
},
|
||||||
|
{ regex: [/mini\Wseries/gim], displayName: "Mini-Series" },
|
||||||
];
|
];
|
||||||
const miniSeries = [/mini\Wseries/gim];
|
|
||||||
|
|
||||||
const matches = paperback
|
const matches = map(issueTypeMatchers, (matcher) => {
|
||||||
|
return getIssueTypeDisplayName(deck, matcher.regex, matcher.displayName);
|
||||||
|
});
|
||||||
|
return compact(matches)[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
const getIssueTypeDisplayName = (
|
||||||
|
deck: string,
|
||||||
|
regexPattern: RegExp[],
|
||||||
|
displayName: string,
|
||||||
|
) => {
|
||||||
|
const matches = [...regexPattern]
|
||||||
.map((regex) => {
|
.map((regex) => {
|
||||||
return deck.match(regex);
|
return deck.match(regex);
|
||||||
})
|
})
|
||||||
@@ -16,6 +32,8 @@ export const detectTradePaperbacks = (deck): any => {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// console.log(compact(matches));
|
const results = flatten(compact(matches));
|
||||||
return compact(matches);
|
if (!isEmpty(results)) {
|
||||||
|
return { displayName, results };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user