Skip to content

Commit

Permalink
Add route and schema for migrating mediafusion IDs to IMDb IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdzumair committed Jan 9, 2025
1 parent 361b6ba commit f2e9e51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions db/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,9 @@ class CacheSubmitResponse(BaseModel):

success: bool
message: str


class MigrateID(BaseModel):
mediafusion_id: str
imdb_id: str
media_type: Literal["movie", "series"]
18 changes: 18 additions & 0 deletions scrapers/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,21 @@ async def block_torrent(block_data: schemas.BlockTorrent):
status_code=500, detail=f"Failed to block torrent: {str(e)}"
)
return {"status": f"Torrent {block_data.info_hash} has been successfully blocked."}


@router.post("/migrate_id", tags=["scraper"])
async def migrate_id(migrate_data: schemas.MigrateID):
# convert mediafusion id to imdb id
await TorrentStreams.find({"meta_id": migrate_data.mediafusion_id}).update(
{"$set": {"meta_id": migrate_data.imdb_id}}
)
await MediaFusionMetaData.get_motor_collection().delete_one(
{"_id": migrate_data.mediafusion_id}
)
if migrate_data.media_type == "series":
await get_series_data_by_id(migrate_data.imdb_id)
else:
await get_movie_data_by_id(migrate_data.imdb_id)
return {
"status": f"Successfully migrated {migrate_data.mediafusion_id} to {migrate_data.imdb_id}."
}

0 comments on commit f2e9e51

Please sign in to comment.