DLsiteの新しいアフィリエイトURL構造に対応
This commit is contained in:
@@ -53,17 +53,19 @@ class DLsiteResolver implements Resolver
|
||||
public function resolve(string $url): Metadata
|
||||
{
|
||||
//アフィリエイトの場合は普通のURLに変換
|
||||
if (strpos($url, '/dlaf/=/link/') !== false) {
|
||||
preg_match('~www\.dlsite\.com/(?P<genre>.+)/dlaf/=/link/work/aid/.+/id/(?P<titleId>..\d+)(\.html)?~', $url, $matches);
|
||||
// ID型
|
||||
if (strpos($url, '/dlaf/=/link/') !== false || preg_match('~/dlaf/=(/.+/.+)?/link/~', $url)) {
|
||||
preg_match('~www\.dlsite\.com/(?P<genre>.+)/dlaf/=(/.+/.+)?/link/work/aid/(?P<AffiliateId>.+)/id/(?P<titleId>..\d+)(\.html)?~', $url, $matches);
|
||||
$url = "https://www.dlsite.com/{$matches['genre']}/work/=/product_id/{$matches['titleId']}.html";
|
||||
}
|
||||
// URL型
|
||||
if (strpos($url, '/dlaf/=/aid/') !== false) {
|
||||
preg_match('~www\.dlsite\.com/.+/dlaf/=/aid/.+/url/(?P<url>.+)~', $url, $matches);
|
||||
$affiliate_url = urldecode($matches['url']);
|
||||
if (preg_match('~www\.dlsite\.com/.+/(work|announce)/=/product_id/..\d+(\.html)?~', $affiliate_url, $matches)) {
|
||||
$url = $affiliate_url;
|
||||
$affiliateUrl = urldecode($matches['url']);
|
||||
if (preg_match('~www\.dlsite\.com/.+/(work|announce)/=/product_id/..\d+(\.html)?~', $affiliateUrl, $matches)) {
|
||||
$url = $affiliateUrl;
|
||||
} else {
|
||||
throw new \RuntimeException("アフィリエイト先のリンクがDLsiteのタイトルではありません: $affiliate_url");
|
||||
throw new \RuntimeException("アフィリエイト先のリンクがDLsiteのタイトルではありません: $affiliateUrl");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ class MetadataResolver implements Resolver
|
||||
'~ec\.toranoana\.(jp|shop)/(tora|joshi)(_[rd]+)?/(ec|digi)/item/~' => ToranoanaResolver::class,
|
||||
'~iwara\.tv/(videos|images)/.*~' => IwaraResolver::class,
|
||||
'~www\.dlsite\.com/.*/(work|announce)/=/product_id/..\d+(\.html)?~' => DLsiteResolver::class,
|
||||
'~www\.dlsite\.com/.*/dlaf/=/link/(work|announce)/aid/.+/..\d+(\.html)?~' => DLsiteResolver::class,
|
||||
'~www\.dlsite\.com/.*/dlaf/=(/.+/.+)?/link/work/aid/.+(/id)?/..\d+(\.html)?~' => DLsiteResolver::class,
|
||||
'~www\.dlsite\.com/.*/dlaf/=/aid/.+/url/.+~' => DLsiteResolver::class,
|
||||
'~dlsite\.jp/...tw/..\d+~' => DLsiteResolver::class,
|
||||
'~www\.pixiv\.net/member_illust\.php\?illust_id=\d+~' => PixivResolver::class,
|
||||
|
Reference in New Issue
Block a user