mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
refactor: updating resources (#720)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<a href="https://discordapp.com/invite/m9zbVyQ"><img src="https://img.shields.io/discord/354388306580078594.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2"></a>
|
||||
<a href="https://github.com/AnimeThemes/animethemes-server/blob/main/LICENSE"><img src="https://img.shields.io/github/license/AnimeThemes/animethemes-server"></a>
|
||||
<a href="https://reddit.com/r/AnimeThemes"><img src="https://img.shields.io/reddit/subreddit-subscribers/AnimeThemes?style=social"></a>
|
||||
<a href="https://twitter.com/AnimeThemesMoe"><img src="https://img.shields.io/twitter/follow/AnimeThemesMoe?style=social"></a>
|
||||
<a href="https://x.com/AnimeThemesMoe"><img src="https://img.shields.io/twitter/follow/AnimeThemesMoe?style=social"></a>
|
||||
</p>
|
||||
|
||||
[**AnimeThemes**](https://animethemes.moe/) is a simple and consistent repository of anime opening and ending themes. We provide direct links to high quality WebMs of your favorite OPs and EDs for your listening and discussion needs.
|
||||
|
||||
@@ -133,7 +133,7 @@ class AnilistAnimeApiAction extends ApiAction
|
||||
protected function getResourcesMapping(): array
|
||||
{
|
||||
return [
|
||||
ResourceSite::TWITTER->value => 'Twitter',
|
||||
ResourceSite::X->value => 'Twitter',
|
||||
ResourceSite::OFFICIAL_SITE->value => 'Official Site',
|
||||
ResourceSite::NETFLIX->value => 'Netflix',
|
||||
ResourceSite::CRUNCHYROLL->value => 'Crunchyroll',
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace App\Actions\Models\Wiki\Anime\ApiAction;
|
||||
|
||||
use App\Actions\Models\Wiki\ApiAction;
|
||||
use App\Enums\Models\Wiki\ImageFacet;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -39,12 +38,7 @@ class LivechartAnimeApiAction extends ApiAction
|
||||
if ($resource instanceof ExternalResource) {
|
||||
$id = $resource->external_id;
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept-encoding' => 'gzip',
|
||||
'connection' => 'Keep-Alive',
|
||||
'host' => 'www.livechart.me',
|
||||
'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 OPR/109.0.0.0',
|
||||
])->withoutVerifying()
|
||||
$response = Http::withUserAgent('AnimeThemes/1.0 (https://animethemes.moe)')
|
||||
->get("https://www.livechart.me/api/v2/anime/$id")
|
||||
->throw()
|
||||
->json();
|
||||
@@ -70,7 +64,7 @@ class LivechartAnimeApiAction extends ApiAction
|
||||
ResourceSite::KITSU->value => 'kitsu_url',
|
||||
ResourceSite::MAL->value => 'mal_url',
|
||||
ResourceSite::OFFICIAL_SITE->value => 'website_url',
|
||||
ResourceSite::TWITTER->value => 'twitter_url',
|
||||
ResourceSite::X->value => 'twitter_url',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ class AttachResourceAction
|
||||
foreach ($this->sites as $resourceSite) {
|
||||
$link = Arr::get($this->fields, $resourceSite->name);
|
||||
|
||||
if (empty($link)) continue;
|
||||
|
||||
$this->createResource($link, $resourceSite, $this->model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ enum ResourceSite: int
|
||||
|
||||
// Official Media
|
||||
case OFFICIAL_SITE = 0;
|
||||
case TWITTER = 1;
|
||||
case X = 1;
|
||||
|
||||
// Tracking Sites
|
||||
case ANIDB = 2;
|
||||
@@ -63,7 +63,7 @@ enum ResourceSite: int
|
||||
public static function getDomain(?int $value): ?string
|
||||
{
|
||||
return match ($value) {
|
||||
ResourceSite::TWITTER->value => 'twitter.com',
|
||||
ResourceSite::X->value => 'x.com',
|
||||
ResourceSite::ANIDB->value => 'anidb.net',
|
||||
ResourceSite::ANILIST->value => 'anilist.co',
|
||||
ResourceSite::ANIME_PLANET->value => 'www.anime-planet.com',
|
||||
@@ -141,7 +141,8 @@ enum ResourceSite: int
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::get($link)
|
||||
$response = Http::withUserAgent('AnimeThemes/1.0 (https://animethemes.moe)')
|
||||
->get($link)
|
||||
->throw()
|
||||
->body();
|
||||
|
||||
@@ -206,7 +207,7 @@ enum ResourceSite: int
|
||||
{
|
||||
return match ($modelClass) {
|
||||
Anime::class => [
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::ANIDB,
|
||||
ResourceSite::ANILIST,
|
||||
ResourceSite::ANIME_PLANET,
|
||||
@@ -225,7 +226,7 @@ enum ResourceSite: int
|
||||
ResourceSite::LIVECHART,
|
||||
],
|
||||
Artist::class => [
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::ANIDB,
|
||||
ResourceSite::ANILIST,
|
||||
ResourceSite::ANIME_PLANET,
|
||||
@@ -248,7 +249,7 @@ enum ResourceSite: int
|
||||
ResourceSite::WIKI,
|
||||
],
|
||||
Studio::class => [
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::ANIDB,
|
||||
ResourceSite::ANILIST,
|
||||
ResourceSite::ANIME_PLANET,
|
||||
@@ -274,12 +275,12 @@ enum ResourceSite: int
|
||||
{
|
||||
if ($modelClass === Anime::class) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => "https://twitter.com/$slug",
|
||||
ResourceSite::X => "https://x.com/$slug",
|
||||
ResourceSite::ANIDB => "https://anidb.net/anime/$id",
|
||||
ResourceSite::ANILIST => "https://anilist.co/anime/$id",
|
||||
ResourceSite::ANIME_PLANET => "https://www.anime-planet.com/anime/$slug",
|
||||
ResourceSite::ANN => "https://www.animenewsnetwork.com/encyclopedia/anime.php?id=$id",
|
||||
ResourceSite::KITSU => "https://kitsu.io/anime/$slug",
|
||||
ResourceSite::KITSU => "https://kitsu.io/anime/$id",
|
||||
ResourceSite::LIVECHART => "https://www.livechart.me/anime/$id",
|
||||
ResourceSite::MAL => "https://myanimelist.net/anime/$id",
|
||||
ResourceSite::YOUTUBE => "https://www.youtube.com/@$slug",
|
||||
@@ -295,7 +296,7 @@ enum ResourceSite: int
|
||||
|
||||
if ($modelClass === Artist::class) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => "https://twitter.com/$slug",
|
||||
ResourceSite::X => "https://x.com/$slug",
|
||||
ResourceSite::ANIDB => "https://anidb.net/creator/$id",
|
||||
ResourceSite::ANILIST => "https://anilist.co/staff/$id",
|
||||
ResourceSite::ANIME_PLANET => "https://www.anime-planet.com/people/$slug",
|
||||
@@ -322,7 +323,7 @@ enum ResourceSite: int
|
||||
|
||||
if ($modelClass === Studio::class) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => "https://twitter.com/$slug",
|
||||
ResourceSite::X => "https://x.com/$slug",
|
||||
ResourceSite::ANIDB => "https://anidb.net/creator/$id",
|
||||
ResourceSite::ANILIST => "https://anilist.co/studio/$id",
|
||||
ResourceSite::ANIME_PLANET => "https://www.anime-planet.com/anime/studios/$slug",
|
||||
@@ -346,7 +347,7 @@ enum ResourceSite: int
|
||||
// The first capture group refers to $type, the second to $id and $slug of the formatResourceLink method.
|
||||
if ($model instanceof Anime) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => '/^https:\/\/(twitter)\.com\/(\w+)/',
|
||||
ResourceSite::X => '/^https:\/\/(x)\.com\/(\w+)/',
|
||||
ResourceSite::ANILIST => '/^https:\/\/anilist\.co\/(anime)\/(\d+)$/',
|
||||
ResourceSite::ANIME_PLANET => '/^https:\/\/www\.anime-planet\.com\/(anime)\/([a-zA-Z0-9-]+)$/',
|
||||
ResourceSite::ANN => '/^https:\/\/www\.animenewsnetwork\.com\/encyclopedia\/(anime)\.php\?id=(\d+)$/',
|
||||
@@ -367,7 +368,7 @@ enum ResourceSite: int
|
||||
|
||||
if ($model instanceof Artist) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => '/^https:\/\/(twitter)\.com\/(\w+)$/',
|
||||
ResourceSite::X => '/^https:\/\/(x)\.com\/(\w+)$/',
|
||||
ResourceSite::ANIDB => '/^https:\/\/anidb\.net\/(creator)\/(?:virtual\/)?(\d+)$/',
|
||||
ResourceSite::ANILIST => '/^https:\/\/anilist\.co\/(staff)\/(\d+)$/',
|
||||
ResourceSite::ANIME_PLANET => '/^https:\/\/www\.anime-planet\.com\/(people)\/([a-zA-Z0-9-]+)$/',
|
||||
@@ -394,7 +395,7 @@ enum ResourceSite: int
|
||||
|
||||
if ($model instanceof Studio) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => '/^https:\/\/(twitter)\.com\/(\w+)$/',
|
||||
ResourceSite::X => '/^https:\/\/(x)\.com\/(\w+)$/',
|
||||
ResourceSite::ANIDB => '/^https:\/\/anidb\.net\/(creator)\/(?:virtual\/)?(\d+)$/',
|
||||
ResourceSite::ANILIST => '/^https:\/\/anilist\.co\/(studio)\/(\d+)$/',
|
||||
ResourceSite::ANIME_PLANET => '/^https:\/\/www\.anime-planet\.com\/anime\/(studios)\/([a-zA-Z0-9-]+)$/',
|
||||
@@ -417,7 +418,7 @@ enum ResourceSite: int
|
||||
{
|
||||
if ($modelClass === Anime::class) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => '/^https:\/\/twitter\.com\/\w+$/',
|
||||
ResourceSite::X => '/^https:\/\/x\.com\/\w+$/',
|
||||
ResourceSite::ANIDB => '/^https:\/\/anidb\.net\/anime\/\d+$/',
|
||||
ResourceSite::ANILIST => '/^https:\/\/anilist\.co\/anime\/\d+$/',
|
||||
ResourceSite::ANIME_PLANET => '/^https:\/\/www\.anime-planet\.com\/anime\/[a-zA-Z0-9-]+$/',
|
||||
@@ -440,7 +441,7 @@ enum ResourceSite: int
|
||||
|
||||
if ($modelClass === Artist::class) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => '/^https:\/\/twitter\.com\/\w+$/',
|
||||
ResourceSite::X => '/^https:\/\/x\.com\/\w+$/',
|
||||
ResourceSite::ANIDB => '/^https:\/\/anidb\.net\/creator\/(?:virtual\/)?\d+$/',
|
||||
ResourceSite::ANILIST => '/^https:\/\/anilist\.co\/staff\/\d+$/',
|
||||
ResourceSite::ANIME_PLANET => '/^https:\/\/www\.anime-planet\.com\/people\/[a-zA-Z0-9-]+$/',
|
||||
@@ -471,7 +472,7 @@ enum ResourceSite: int
|
||||
|
||||
if ($modelClass === Studio::class) {
|
||||
return match ($this) {
|
||||
ResourceSite::TWITTER => '/^https:\/\/twitter\.com\/\w+$/',
|
||||
ResourceSite::X => '/^https:\/\/x\.com\/\w+$/',
|
||||
ResourceSite::ANIDB => '/^https:\/\/anidb\.net\/creator\/(?:virtual\/)?\d+$/',
|
||||
ResourceSite::ANILIST => '/^https:\/\/anilist\.co\/studio\/\d+$/',
|
||||
ResourceSite::ANIME_PLANET => '/^https:\/\/www\.anime-planet\.com\/anime\/studios\/[a-zA-Z0-9-]+$/',
|
||||
|
||||
@@ -34,7 +34,7 @@ class AttachAnimeResourceAction extends AttachResourceAction
|
||||
ResourceSite::LIVECHART,
|
||||
ResourceSite::MAL,
|
||||
ResourceSite::OFFICIAL_SITE,
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::YOUTUBE,
|
||||
ResourceSite::WIKI,
|
||||
]);
|
||||
|
||||
@@ -231,7 +231,7 @@ class BackfillAnimeAction extends BaseAction implements ShouldQueue
|
||||
self::BACKFILL_ANN_RESOURCE => [ResourceSite::ANN],
|
||||
self::BACKFILL_ANIME_PLANET_RESOURCE => [ResourceSite::ANIME_PLANET],
|
||||
self::BACKFILL_OTHER_RESOURCES => [
|
||||
ResourceSite::TWITTER, ResourceSite::OFFICIAL_SITE, ResourceSite::NETFLIX, ResourceSite::CRUNCHYROLL,
|
||||
ResourceSite::X, ResourceSite::OFFICIAL_SITE, ResourceSite::NETFLIX, ResourceSite::CRUNCHYROLL,
|
||||
ResourceSite::HIDIVE, ResourceSite::AMAZON_PRIME_VIDEO, ResourceSite::HULU, ResourceSite::DISNEY_PLUS,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -33,7 +33,7 @@ class AttachArtistResourceAction extends AttachResourceAction
|
||||
ResourceSite::MAL,
|
||||
ResourceSite::OFFICIAL_SITE,
|
||||
ResourceSite::SPOTIFY,
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::YOUTUBE,
|
||||
ResourceSite::YOUTUBE_MUSIC,
|
||||
ResourceSite::WIKI,
|
||||
|
||||
@@ -34,7 +34,7 @@ class AttachAnimeResourceHeaderAction extends AttachResourceHeaderAction
|
||||
ResourceSite::LIVECHART,
|
||||
ResourceSite::MAL,
|
||||
ResourceSite::OFFICIAL_SITE,
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::YOUTUBE,
|
||||
ResourceSite::WIKI,
|
||||
]);
|
||||
|
||||
@@ -231,7 +231,7 @@ class BackfillAnimeHeaderAction extends BaseHeaderAction implements ShouldQueue
|
||||
self::BACKFILL_ANN_RESOURCE => [ResourceSite::ANN],
|
||||
self::BACKFILL_ANIME_PLANET_RESOURCE => [ResourceSite::ANIME_PLANET],
|
||||
self::BACKFILL_OTHER_RESOURCES => [
|
||||
ResourceSite::TWITTER, ResourceSite::OFFICIAL_SITE, ResourceSite::NETFLIX, ResourceSite::CRUNCHYROLL,
|
||||
ResourceSite::X, ResourceSite::OFFICIAL_SITE, ResourceSite::NETFLIX, ResourceSite::CRUNCHYROLL,
|
||||
ResourceSite::HIDIVE, ResourceSite::AMAZON_PRIME_VIDEO, ResourceSite::HULU, ResourceSite::DISNEY_PLUS,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -33,7 +33,7 @@ class AttachArtistResourceHeaderAction extends AttachResourceHeaderAction
|
||||
ResourceSite::MAL,
|
||||
ResourceSite::OFFICIAL_SITE,
|
||||
ResourceSite::SPOTIFY,
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::YOUTUBE,
|
||||
ResourceSite::YOUTUBE_MUSIC,
|
||||
ResourceSite::WIKI,
|
||||
|
||||
@@ -17,7 +17,7 @@ use App\Filament\Tabs\Anime\Resource\AnimeKitsuResourceTab;
|
||||
use App\Filament\Tabs\Anime\Resource\AnimeMalResourceTab;
|
||||
use App\Filament\Tabs\Anime\Resource\AnimeOfficialSiteResourceTab;
|
||||
use App\Filament\Tabs\Anime\Resource\AnimePlanetResourceTab;
|
||||
use App\Filament\Tabs\Anime\Resource\AnimeTwitterResourceTab;
|
||||
use App\Filament\Tabs\Anime\Resource\AnimeXResourceTab;
|
||||
use App\Filament\Tabs\Anime\Resource\AnimeYoutubeResourceTab;
|
||||
use App\Filament\Tabs\Anime\Studio\AnimeStudioTab;
|
||||
use App\Models\Wiki\Anime as AnimeModel;
|
||||
@@ -82,7 +82,7 @@ class ListAnimes extends BaseListResources
|
||||
AnimeMalResourceTab::class,
|
||||
AnimeOfficialSiteResourceTab::class,
|
||||
AnimePlanetResourceTab::class,
|
||||
AnimeTwitterResourceTab::class,
|
||||
AnimeXResourceTab::class,
|
||||
AnimeYoutubeResourceTab::class,
|
||||
AnimeStreamingResourceTab::class,
|
||||
AnimeStudioTab::class,
|
||||
|
||||
@@ -16,7 +16,7 @@ use App\Filament\Tabs\Artist\Resource\ArtistAnnResourceTab;
|
||||
use App\Filament\Tabs\Artist\Resource\ArtistMalResourceTab;
|
||||
use App\Filament\Tabs\Artist\Resource\ArtistOfficialSiteResourceTab;
|
||||
use App\Filament\Tabs\Artist\Resource\ArtistSpotifyResourceTab;
|
||||
use App\Filament\Tabs\Artist\Resource\ArtistTwitterResourceTab;
|
||||
use App\Filament\Tabs\Artist\Resource\ArtistXResourceTab;
|
||||
use App\Filament\Tabs\Artist\Resource\ArtistYoutubeResourceTab;
|
||||
use App\Filament\Tabs\Artist\Song\ArtistSongTab;
|
||||
use App\Models\Wiki\Artist as ArtistModel;
|
||||
@@ -81,7 +81,7 @@ class ListArtists extends BaseListResources
|
||||
ArtistMalResourceTab::class,
|
||||
ArtistOfficialSiteResourceTab::class,
|
||||
ArtistSpotifyResourceTab::class,
|
||||
ArtistTwitterResourceTab::class,
|
||||
ArtistXResourceTab::class,
|
||||
ArtistYoutubeResourceTab::class,
|
||||
ArtistSongTab::class,
|
||||
]);
|
||||
|
||||
+4
-4
@@ -8,9 +8,9 @@ use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Filament\Tabs\Anime\AnimeResourceTab;
|
||||
|
||||
/**
|
||||
* Class AnimeTwitterResourceTab.
|
||||
* Class AnimeXResourceTab.
|
||||
*/
|
||||
class AnimeTwitterResourceTab extends AnimeResourceTab
|
||||
class AnimeXResourceTab extends AnimeResourceTab
|
||||
{
|
||||
/**
|
||||
* Get the key for the tab.
|
||||
@@ -19,7 +19,7 @@ class AnimeTwitterResourceTab extends AnimeResourceTab
|
||||
*/
|
||||
public static function getKey(): string
|
||||
{
|
||||
return 'anime-twitter-resource-tab';
|
||||
return 'anime-x-resource-tab';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,6 +29,6 @@ class AnimeTwitterResourceTab extends AnimeResourceTab
|
||||
*/
|
||||
protected static function site(): ResourceSite
|
||||
{
|
||||
return ResourceSite::TWITTER;
|
||||
return ResourceSite::X;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -8,9 +8,9 @@ use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Filament\Tabs\Artist\ArtistResourceTab;
|
||||
|
||||
/**
|
||||
* Class ArtistTwitterResourceTab.
|
||||
* Class ArtistXResourceTab.
|
||||
*/
|
||||
class ArtistTwitterResourceTab extends ArtistResourceTab
|
||||
class ArtistXResourceTab extends ArtistResourceTab
|
||||
{
|
||||
/**
|
||||
* Get the key for the tab.
|
||||
@@ -19,7 +19,7 @@ class ArtistTwitterResourceTab extends ArtistResourceTab
|
||||
*/
|
||||
public static function getKey(): string
|
||||
{
|
||||
return 'artist-twitter-resource-tab';
|
||||
return 'artist-x-resource-tab';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,6 +29,6 @@ class ArtistTwitterResourceTab extends ArtistResourceTab
|
||||
*/
|
||||
protected static function site(): ResourceSite
|
||||
{
|
||||
return ResourceSite::TWITTER;
|
||||
return ResourceSite::X;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders\Wiki;
|
||||
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Exception;
|
||||
use Http\Client\Exception\RequestException;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ResourceAnimePlanetSeeder.
|
||||
*/
|
||||
class ResourceAnimePlanetSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
/** @var ExternalResource[] $resources */
|
||||
$resources = ExternalResource::query()
|
||||
->whereHas(ExternalResource::RELATION_ANIME)
|
||||
->where(ExternalResource::ATTRIBUTE_SITE, ResourceSite::ANIME_PLANET->value)
|
||||
->where(ExternalResource::ATTRIBUTE_EXTERNAL_ID, null)
|
||||
->get();
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
try {
|
||||
$response = Http::withUserAgent('AnimeThemes/1.0 (https://animethemes.moe)')
|
||||
->get($resource->link)
|
||||
->throw()
|
||||
->body();
|
||||
|
||||
$id = Str::match(
|
||||
'/["\']?ENTRY_INFO["\']? *: *{.*id["\']? *: *["\']?(\d+)["\']? *,/s',
|
||||
$response
|
||||
);
|
||||
|
||||
if (empty($id)) continue;
|
||||
|
||||
echo "Updating {$resource->link} to external_id {$id}";
|
||||
echo "\n";
|
||||
|
||||
$resource->update([
|
||||
ExternalResource::ATTRIBUTE_EXTERNAL_ID => intval($id)
|
||||
]);
|
||||
} catch (RequestException $e) {
|
||||
echo $e;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders\Wiki;
|
||||
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Exception;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Class ResourceTwitterXSeeder.
|
||||
*/
|
||||
class ResourceTwitterXSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
ExternalResource::query()
|
||||
->where(ExternalResource::ATTRIBUTE_LINK, 'like', 'https://twitter.com/%')
|
||||
->update([
|
||||
ExternalResource::ATTRIBUTE_LINK => DB::raw("REPLACE(link, 'https://twitter.com/', 'https://x.com/')")
|
||||
]);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -75,7 +75,7 @@ return [
|
||||
],
|
||||
ResourceSite::class => [
|
||||
ResourceSite::OFFICIAL_SITE->name => 'Official Website',
|
||||
ResourceSite::TWITTER->name => 'Twitter',
|
||||
ResourceSite::X->name => 'X',
|
||||
ResourceSite::ANIDB->name => 'aniDB',
|
||||
ResourceSite::ANILIST->name => 'AniList',
|
||||
ResourceSite::ANIME_PLANET->name => 'Anime-Planet',
|
||||
|
||||
@@ -200,8 +200,8 @@ return [
|
||||
'official_site' => [
|
||||
'help' => 'Ex: https://kaguya.love/',
|
||||
],
|
||||
'twitter' => [
|
||||
'help' => 'Ex: https://twitter.com/AnimeThemesMoe',
|
||||
'x' => [
|
||||
'help' => 'Ex: https://x.com/AnimeThemesMoe',
|
||||
],
|
||||
'anidb' => [
|
||||
'help' => 'Ex: https://anidb.net/anime/11746, https://anidb.net/creator/10759',
|
||||
@@ -216,7 +216,7 @@ return [
|
||||
'help' => 'Ex: https://www.animenewsnetwork.com/encyclopedia/anime.php?id=18558',
|
||||
],
|
||||
'kitsu' => [
|
||||
'help' => 'Ex: https://kitsu.io/anime/hibike-euphonium-2',
|
||||
'help' => 'Ex: https://kitsu.io/anime/hibike-euphonium-2, https://kitsu.io/anime/11474',
|
||||
],
|
||||
'livechart' => [
|
||||
'help' => 'Ex: https://www.livechart.me/anime/11873',
|
||||
|
||||
@@ -66,7 +66,7 @@ class ResourceLinkFormatTest extends TestCase
|
||||
{
|
||||
/** @var ResourceSite $site */
|
||||
$site = Arr::random([
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::ANIDB,
|
||||
ResourceSite::ANILIST,
|
||||
ResourceSite::ANIME_PLANET,
|
||||
@@ -97,7 +97,7 @@ class ResourceLinkFormatTest extends TestCase
|
||||
{
|
||||
/** @var ResourceSite $site */
|
||||
$site = Arr::random([
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::ANIDB,
|
||||
ResourceSite::ANILIST,
|
||||
ResourceSite::ANIME_PLANET,
|
||||
@@ -156,7 +156,7 @@ class ResourceLinkFormatTest extends TestCase
|
||||
{
|
||||
/** @var ResourceSite $site */
|
||||
$site = Arr::random([
|
||||
ResourceSite::TWITTER,
|
||||
ResourceSite::X,
|
||||
ResourceSite::ANIDB,
|
||||
ResourceSite::ANILIST,
|
||||
ResourceSite::ANIME_PLANET,
|
||||
|
||||
Reference in New Issue
Block a user