🔧 Fixed a long standing issue with CV-sourced comics, which should not be scraped again
This commit is contained in:
@@ -154,66 +154,58 @@ export const fetchVolumeGroups = () => (dispatch) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
export const fetchComicVineMatches = (searchPayload) => (dispatch) => {
|
||||
try {
|
||||
const issueString = searchPayload.rawFileDetails.name;
|
||||
const issueSearchQuery: IComicVineSearchQuery = refineQuery(issueString);
|
||||
let seriesSearchQuery: IComicVineSearchQuery = {} as IComicVineSearchQuery;
|
||||
if (searchPayload.rawFileDetails.containedIn !== "comics") {
|
||||
seriesSearchQuery = refineQuery(
|
||||
searchPayload.rawFileDetails.containedIn.split("/").pop(),
|
||||
);
|
||||
}
|
||||
export const fetchComicVineMatches =
|
||||
(searchPayload, issueSearchQuery, seriesSearchQuery?) => (dispatch) => {
|
||||
try {
|
||||
dispatch({
|
||||
type: CV_API_CALL_IN_PROGRESS,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: CV_API_CALL_IN_PROGRESS,
|
||||
});
|
||||
|
||||
axios
|
||||
.request({
|
||||
url: `${COMICBOOKINFO_SERVICE_URI}/fetchresource`,
|
||||
method: "POST",
|
||||
data: {
|
||||
format: "json",
|
||||
sort: "name%3Aasc",
|
||||
// hack
|
||||
query: issueSearchQuery.searchParams.searchTerms.name
|
||||
.replace(/[^a-zA-Z0-9 ]/g, "")
|
||||
.trim(),
|
||||
fieldList: "id",
|
||||
limit: "20",
|
||||
offset: "0",
|
||||
resources: "issue",
|
||||
scorerConfiguration: {
|
||||
searchQuery: {
|
||||
axios
|
||||
.request({
|
||||
url: `${COMICBOOKINFO_SERVICE_URI}/fetchresource`,
|
||||
method: "POST",
|
||||
data: {
|
||||
format: "json",
|
||||
sort: "name%3Aasc",
|
||||
// hack
|
||||
query: issueSearchQuery.searchParams.searchTerms.name
|
||||
.replace(/[^a-zA-Z0-9 ]/g, "")
|
||||
.trim(),
|
||||
fieldList: "id",
|
||||
limit: "20",
|
||||
offset: "0",
|
||||
resources: "issue",
|
||||
scorerConfiguration: {
|
||||
searchQuery: {
|
||||
issue: issueSearchQuery,
|
||||
series: seriesSearchQuery,
|
||||
},
|
||||
rawFileDetails: searchPayload.rawFileDetails,
|
||||
},
|
||||
},
|
||||
transformResponse: (r) => {
|
||||
const matches = JSON.parse(r);
|
||||
return sortBy(matches, (match) => -match.score);
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: CV_SEARCH_SUCCESS,
|
||||
searchResults: response.data,
|
||||
searchQueryObject: {
|
||||
issue: issueSearchQuery,
|
||||
series: seriesSearchQuery,
|
||||
},
|
||||
rawFileDetails: searchPayload.rawFileDetails,
|
||||
},
|
||||
},
|
||||
transformResponse: (r) => {
|
||||
const matches = JSON.parse(r);
|
||||
return sortBy(matches, (match) => -match.score);
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: CV_SEARCH_SUCCESS,
|
||||
searchResults: response.data,
|
||||
searchQueryObject: {
|
||||
issue: issueSearchQuery,
|
||||
series: seriesSearchQuery,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* return { issueSearchQuery, series: seriesSearchQuery.searchParams }; */
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
/* return { issueSearchQuery, series: seriesSearchQuery.searchParams }; */
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: CV_CLEANUP,
|
||||
});
|
||||
};
|
||||
dispatch({
|
||||
type: CV_CLEANUP,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ import { RawFileDetails } from "./ComicDetail/RawFileDetails";
|
||||
import { ArchiveOperations } from "./ComicDetail/Tabs/ArchiveOperations";
|
||||
import AcquisitionPanel from "./ComicDetail/AcquisitionPanel";
|
||||
import DownloadsPanel from "./ComicDetail/DownloadsPanel";
|
||||
import { EditMetadataPanel } from "./ComicDetail/EditMetadataPanel";
|
||||
import { Menu } from "./ComicDetail/ActionMenu/Menu";
|
||||
|
||||
import { isEmpty, isUndefined, isNil } from "lodash";
|
||||
@@ -62,7 +63,6 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
|
||||
const comicBookDetailData = useSelector(
|
||||
(state: RootState) => state.comicInfo.comicBookDetail,
|
||||
);
|
||||
|
||||
const { comicObjectId } = useParams<{ comicObjectId: string }>();
|
||||
const userSettings = useSelector((state: RootState) => state.settings.data);
|
||||
const { ADCPPSocket, setADCPPSocket } = useContext(AirDCPPSocketContext);
|
||||
@@ -75,7 +75,6 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isEmpty(ADCPPSocket) && !isNil(userSettings.directConnect)) {
|
||||
console.log(userSettings.directConnect.client.host.hostname);
|
||||
setADCPPSocket(
|
||||
new AirDCPPSocket({
|
||||
protocol: `${userSettings.directConnect.client.host.protocol}`,
|
||||
@@ -118,10 +117,11 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
|
||||
}
|
||||
},
|
||||
},
|
||||
editComicArchive: {
|
||||
content: () => <></>,
|
||||
editComicBookMetadata: {
|
||||
content: () => <EditMetadataPanel />,
|
||||
},
|
||||
};
|
||||
console.log(comicVineSearchQueryObject);
|
||||
|
||||
const [active, setActive] = useState(1);
|
||||
|
||||
|
||||
@@ -1,24 +1,44 @@
|
||||
import { filter, isEmpty, isNil, isUndefined } from "lodash";
|
||||
import React, { ReactElement, useCallback } from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import Select, { components } from "react-select";
|
||||
import { fetchComicVineMatches } from "../../../actions/fileops.actions";
|
||||
import { refineQuery } from "../../../shared/utils/filenameparser.utils";
|
||||
|
||||
export const Menu = (props): ReactElement => {
|
||||
const { data } = props;
|
||||
const { setSlidingPanelContentId, setVisible } = props.handlers;
|
||||
const dispatch = useDispatch();
|
||||
const openDrawerWithCVMatches = useCallback(() => {
|
||||
dispatch(fetchComicVineMatches(data));
|
||||
let seriesSearchQuery: IComicVineSearchQuery = {} as IComicVineSearchQuery;
|
||||
let issueSearchQuery: IComicVineSearchQuery = {} as IComicVineSearchQuery;
|
||||
|
||||
if (!isUndefined(data.rawFileDetails)) {
|
||||
issueSearchQuery = refineQuery(data.rawFileDetails.name);
|
||||
if (data.rawFileDetails.containedIn !== "comics") {
|
||||
seriesSearchQuery = refineQuery(
|
||||
data.rawFileDetails.containedIn.split("/").pop(),
|
||||
);
|
||||
}
|
||||
} else if (!isEmpty(data.sourcedMetadata)) {
|
||||
issueSearchQuery = refineQuery(data.sourcedMetadata.comicvine.name);
|
||||
}
|
||||
|
||||
dispatch(fetchComicVineMatches(data, issueSearchQuery, seriesSearchQuery));
|
||||
setSlidingPanelContentId("CVMatches");
|
||||
setVisible(true);
|
||||
}, [dispatch, data]);
|
||||
|
||||
const openEditMetadataPanel = useCallback(() => {
|
||||
setSlidingPanelContentId("editComicBookMetadata");
|
||||
setVisible(true);
|
||||
}, []);
|
||||
// Actions menu options and handler
|
||||
const CVMatchLabel = (
|
||||
<span>
|
||||
<i className="fa-solid fa-wand-magic"></i> Match on ComicVine
|
||||
</span>
|
||||
);
|
||||
|
||||
const editLabel = (
|
||||
<span>
|
||||
<i className="fa-regular fa-pen-to-square"></i> Edit Metadata
|
||||
@@ -38,11 +58,20 @@ export const Menu = (props): ReactElement => {
|
||||
{ value: "delete-comic", label: deleteLabel },
|
||||
];
|
||||
|
||||
const filteredActionOptions = filter(actionOptions, (item) => {
|
||||
if (isUndefined(data.rawFileDetails)) {
|
||||
return item.value !== "match-on-comic-vine";
|
||||
}
|
||||
return item;
|
||||
});
|
||||
const handleActionSelection = (action) => {
|
||||
switch (action.value) {
|
||||
case "match-on-comic-vine":
|
||||
openDrawerWithCVMatches();
|
||||
break;
|
||||
case "edit-metdata":
|
||||
openEditMetadataPanel();
|
||||
break;
|
||||
default:
|
||||
console.log("No valid action selected.");
|
||||
break;
|
||||
@@ -61,7 +90,7 @@ export const Menu = (props): ReactElement => {
|
||||
}
|
||||
name="actions"
|
||||
isSearchable={false}
|
||||
options={actionOptions}
|
||||
options={filteredActionOptions}
|
||||
onChange={handleActionSelection}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -14,36 +14,38 @@ export const ComicVineMatchPanel = (comicVineData): ReactElement => {
|
||||
console.log(comicVineData);
|
||||
return (
|
||||
<>
|
||||
<div className="card search-criteria-card">
|
||||
<div className="card-content">
|
||||
<ComicVineSearchForm />
|
||||
<p className="is-size-6">Searching against:</p>
|
||||
<div className="field is-grouped is-grouped-multiline">
|
||||
<div className="control">
|
||||
<div className="tags has-addons">
|
||||
<span className="tag">Title</span>
|
||||
<span className="tag is-info">
|
||||
{
|
||||
comicVineSearchQueryObject.issue.searchParams.searchTerms
|
||||
.name
|
||||
}
|
||||
</span>
|
||||
{!isEmpty(comicVineSearchQueryObject) && (
|
||||
<div className="card search-criteria-card">
|
||||
<div className="card-content">
|
||||
<ComicVineSearchForm />
|
||||
<p className="is-size-6">Searching against:</p>
|
||||
<div className="field is-grouped is-grouped-multiline">
|
||||
<div className="control">
|
||||
<div className="tags has-addons">
|
||||
<span className="tag">Title</span>
|
||||
<span className="tag is-info">
|
||||
{
|
||||
comicVineSearchQueryObject.issue.searchParams.searchTerms
|
||||
.name
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="control">
|
||||
<div className="tags has-addons">
|
||||
<span className="tag">Number</span>
|
||||
<span className="tag is-info">
|
||||
{
|
||||
comicVineSearchQueryObject.issue.searchParams.searchTerms
|
||||
.number
|
||||
}
|
||||
</span>
|
||||
<div className="control">
|
||||
<div className="tags has-addons">
|
||||
<span className="tag">Number</span>
|
||||
<span className="tag is-info">
|
||||
{
|
||||
comicVineSearchQueryObject.issue.searchParams.searchTerms
|
||||
.number
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="search-results-container">
|
||||
{!isEmpty(comicVineSearchResults) && (
|
||||
<MatchResult
|
||||
|
||||
@@ -124,10 +124,10 @@ export const DownloadsPanel = (
|
||||
|
||||
return !isNil(props.data) ? (
|
||||
<>
|
||||
{!isNil(downloadProgressTick) ? (
|
||||
<ProgressTick data={downloadProgressTick} />
|
||||
) : null}
|
||||
<div className="columns">
|
||||
<div className="columns is-multiline">
|
||||
{!isNil(downloadProgressTick) ? (
|
||||
<ProgressTick data={downloadProgressTick} />
|
||||
) : null}
|
||||
{!isEmpty(ADCPPSocket) ? (
|
||||
<Bundles data={bundles} />
|
||||
) : (
|
||||
|
||||
7
src/client/components/ComicDetail/EditMetadataPanel.tsx
Normal file
7
src/client/components/ComicDetail/EditMetadataPanel.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import React, { ReactElement } from "react";
|
||||
|
||||
export const EditMetadataPanel = (props): ReactElement => {
|
||||
return <>adsasdasd</>;
|
||||
};
|
||||
|
||||
export default EditMetadataPanel;
|
||||
Reference in New Issue
Block a user