Skip to content

Commit

Permalink
Started to build out movie request
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrogman committed Oct 17, 2023
1 parent 7d9f698 commit d5d86a2
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions regrabarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ async def regrab_callback(self, button):
movie_id = self.movie_data['id']
movie_tmdb = self.movie_data['tmdbId']

await self.interaction.delete_original_response()
if media_info['delete'] == "yes":
await self.interaction.delete_original_response()

# Delete the movie
delete_url = f"{radarr_base_url}/movie/{movie_id}?deleteFiles=true&apikey={radarr_api_key}"
delete_response = perform_request('DELETE', delete_url)
logging.info(f"Deleted {movie_title} with a response of {delete_response}")
# Delete the movie
delete_url = f"{radarr_base_url}/movie/{movie_id}?deleteFiles=true&apikey={radarr_api_key}"
delete_response = perform_request('DELETE', delete_url)
logging.info(f"Deleted {movie_title} with a response of {delete_response}")
else:
# Check if movie exists?
# Check if movie is already downloaded

# Add the movie back (and search for it)
add_url = f"{radarr_base_url}/movie?apikey={radarr_api_key}"
Expand Down Expand Up @@ -187,8 +191,13 @@ async def callback(self, interaction: discord.Interaction):
self.media_info['year'] = selected_movie_data['year']
self.media_info['overview'] = selected_movie_data['overview']

if media_info['delete'] == "yes":
confirm_word = "regrab"
else:
confirm_word = "request"

confirmation_message = (
f"Please confirm that you would like to regrab the following movie:\n"
f"Please confirm that you would like to {confirm_word} the following movie:\n"
f"**Title:** {self.media_info['title']}\n"
f"**Year:** {self.media_info['year']}\n"
f"**Overview:** {self.media_info['overview']}\n"
Expand Down Expand Up @@ -430,6 +439,20 @@ async def regrab_movie(ctx, *, movie: str):
await ctx.response.send_message("Select a movie to regrab", view=MovieSelectorView(movie_results, media_info), ephemeral=True)


# Bot command to "request" (add and search) for movie
@bot.tree.command(name="request_movie", description="Will add and search for selected movie")
@app_commands.describe(movie="What movie should we request?")
async def regrab_movie(ctx, *, movie: str):
movie_results = await fetch_movie(movie)
if not movie_results:
await ctx.response.send_message(
f"{ctx.user.name} no movie matching the following title was found: {movie}")
return
media_info['what'] = 'movie'
media_info['delete'] = 'no'
await ctx.response.send_message("Select a movie to request", view=MovieSelectorView(movie_results, media_info), ephemeral=True)


# Bot command to "regrab" (delete and search) for TV Show Episode
@bot.tree.command(name="regrab_episode", description="Will delete and redownload selected episode")
@app_commands.describe(series="What TV series should we regrab from?")
Expand Down

0 comments on commit d5d86a2

Please sign in to comment.