Core App Modules

Application Pipeline

app.application.create_media_object(params: dict) dict

Create something called media object. this is step 1 of the process of publishing content to instagram. This function is used to create a media object on Instagram. It returns the response from the API.

Args:

params (dict): dictionary of params

API Endpoint:

https://graph.facebook.com/v21.0/{ig-user-id}/media?image_url={image-url}&caption={caption}&access_token={access-token} https://graph.facebook.com/v21.0/{ig-user-id}/media?video_url={video-url}&caption={caption}&access_token={access-token}

Returns:

dict: dictionary containing the response from the API, the url, and the endpoint params used to make the request

app.application.facebook_api_call(url: str, endpointParams: dict, type: str) dict

Request data from endpoint with params. This function is used to make calls to the Facebook API. It returns the response from the API.

Args:

url (str): string of the url endpoint to make request from endpoint_params (dict): dictionary keyed by the names of the url parameters type (str): type of request to be made. Can be “GET” or “POST”

Returns:

dict: dictionary containing the response from the API, the url, and the endpoint params used to make the request

app.application.get_content_publishing_limit(params: dict) dict

Get the api limit for the user

Args:

params: dictionary of params

API Endpoint:

https://graph.facebook.com/v21.0/{ig-user-id}/content_publishing_limit?fields=config,quota_usage

Returns:

dict: dictionary containing the response from the API, the url, and the endpoint params used to make the request

app.application.get_creds() dict

This function is used to get the credentials from the environment variables. It returns a dictionary containing the credentials.

Returns:

dict: dictionary containing access token, client id, client secret, graph domain, graph version, endpoint base, page id, instagram account id, and instagram username

app.application.get_media_object_status(media_object_id: int, params: dict) dict

Check the status of a media object.

Args:

media_object_id (int): id of the media object params (dict): dictionary of params

API Endpoint:

https://graph.facebook.com/v21.0/{ig-container-id}?fields=status_code

Returns:

dict: dictionary containing the response from the API, the url, and the endpoint params used to make the request

app.application.main(youtube_track_url: str, offset_seconds: int | None = <typer.models.OptionInfo object>)
app.application.publish_image(params: dict, image_url: str, caption: str)

Publish image to Instagram.

Args:

params (dict): parameters to be passed image_url (str): url of the image caption (str): Instagram caption

app.application.publish_media(media_object_id: int, params: dict) dict

Publish content to Instagram.

Args:

media_object_id (int): id of the media object params (dict): dictionary of params

API Endpoint:

https://graph.facebook.com/v21.0/{ig-user-id}/media_publish?creation_id={creation-id}&access_token={access-token}

Returns:

dict: dictionary containing the response from the API, the url, and the endpoint params used to make the request

app.application.publish_video(params: dict, video_url: str, caption: str)

Publish video to Instagram.

Args:

params (dict): parameters to be passed video_url (str): url of the video caption (str): Instagram caption

CLI

Configuration

class app.config.Config

Bases: object

static get(name: str, default: Any = None) str | Any
giphy_api_key() str | None
imgur_client_id() str
imgur_client_secret() str
imgur_refresh_token() str
instagram_creds() dict[str, str]
static require(name: str) str

YouTube Pipeline

This module’s purpose is to expose a function get_bateman_video() that takes in a youtube video URL, generates the upload-able bateman video, and returns the file path to that video.

class app.youtube.main.BatemanVideoArtifacts

Bases: TypedDict

audio_path: Path | str
delay_in_seconds: int
final_video_path: Path
thumbnail_path: Path
video_only_path: Path
app.youtube.main.build_bateman_video(url: str, offset_seconds: int | None = None) BatemanVideoArtifacts
app.youtube.main.combine_audio_video(video_path: Path, audio_path: Path, delay_in_seconds: int) Path

Combines the given audio and video with delay added from start of the audio.

Args:

video_path (Path): path to the video audio_path (Path): path to the audio

Returns:

Path: final output video path

app.youtube.main.generate_video(bg_image_path: Path) Path

Generate patrick bateman walking to music video using the given background image. Also shows a progress bar.

Args:

bg_image_path (str): path to the background image (cover art)

Returns:

str: path to the output video

app.youtube.main.get_bateman_video(url: str) Path

Generates a video of Patrick Bateman walking to the music of the given Youtube or YTMusic track URL. The video is generated by combining the cover art of the track and the 30-second preview of the track. The video is generated using the generateVideoYoutube.sh script and the audio is combined with the video using the combineAudioVideo.sh script. The final video is saved in the assets folder.

Args:

url (str): Youtube or YTMusic URL of the song

Returns:

str : path to the final output video.