Skip to content

Account

Bases: TMDB

Account functionality.

https://developers.themoviedb.org/3/account

https://www.themoviedb.org/documentation/api/sessions

Source code in src/tmdb_client_py/account.py
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
class Account(TMDB):
    """
    Account functionality.

    See: https://developers.themoviedb.org/3/account
         https://www.themoviedb.org/documentation/api/sessions
    """

    BASE_PATH = "account"
    URLS = {
        "info": "",
        "lists": "/{id}/lists",
        "favorite_movies": "/{id}/favorite/movies",
        "favorite_tv": "/{id}/favorite/tv",
        "favorite": "/{id}/favorite",
        "rated_movies": "/{id}/rated/movies",
        "rated_tv": "/{id}/rated/tv",
        "rated_tv_episodes": "/{id}/rated/tv/episodes",
        "watchlist_movies": "/{id}/watchlist/movies",
        "watchlist_tv": "/{id}/watchlist/tv",
        "watchlist": "/{id}/watchlist",
    }

    def __init__(self, session_id):
        super().__init__()
        self.session_id = session_id

    def info(self, **kwargs):
        """
        Get your account details.

        Args:

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_path("info")

        response = self._GET(path, kwargs)
        self.id = response["id"]
        self._set_attrs_to_values(response)
        return response

    def lists(self, **kwargs):
        """
        Get all of the lists created by an account. Will include private lists
        if you are the owner.

        Args:
            language: (optional) ISO 639-1 code.
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("lists")

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def favorite_movies(self, **kwargs):
        """
        Get the list of your favorite movies.

        Args:
            language: (optional) ISO 639-1 code.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("favorite_movies")

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def favorite_tv(self, **kwargs):
        """
        Get the list of your favorite TV shows.

        Args:
            language: (optional) ISO 639-1 code.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("favorite_tv")

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def favorite(self, **kwargs):
        """
        This method allows you to mark a movie or TV show as a favorite item.

        Args:
            media_type: 'movie' | 'tv'
            media_id: The id of the media.
            favorite: True (to add) | False (to remove).

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("favorite")

        payload = {
            "media_type": kwargs.pop("media_type", None),
            "media_id": kwargs.pop("media_id", None),
            "favorite": kwargs.pop("favorite", None),
        }

        response = self._POST(path, kwargs, payload)
        self._set_attrs_to_values(response)
        return response

    def rated_movies(self, **kwargs):
        """
        Get a list of all the movies you have rated.

        Args:
            language: (optional) ISO 639-1 value.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("rated_movies")

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def rated_tv(self, **kwargs):
        """
        Get a list of all the TV shows you have rated.

        Args:
            language: (optional) ISO 639-1 value.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("rated_tv")
        kwargs.update({"session_id": self.session_id})

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def rated_tv_episodes(self, **kwargs):
        """
        Get a list of all the TV episodes you have rated.

        Args:
            language: (optional) ISO 639-1 value.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("rated_tv_episodes")
        kwargs.update({"session_id": self.session_id})

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def watchlist_movies(self, **kwargs):
        """
        Get a list of all the movies you have added to your watchlist.

        Args:
            language: (optional) ISO 639-1 value.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("watchlist_movies")
        kwargs.update({"session_id": self.session_id})

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def watchlist_tv(self, **kwargs):
        """
        Get a list of all the TV shows you have added to your watchlist.

        Args:
            language: (optional) ISO 639-1 value.
            sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
            page: (optional) Minimum 1, maximum 1000, default 1.

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("watchlist_tv")
        kwargs.update({"session_id": self.session_id})

        response = self._GET(path, kwargs)
        self._set_attrs_to_values(response)
        return response

    def watchlist(self, **kwargs):
        """
        Add a movie or TV show to your watchlist.

        Args:
            media_type: 'movie' | 'tv'
            media_id: The id of the media.
            watchlist: True (to add) | False (to remove).

        Returns:
            A dict representation of the JSON returned from the API.
        """
        path = self._get_id_path("watchlist")
        kwargs.update({"session_id": self.session_id})

        payload = {
            "media_type": kwargs.pop("media_type", None),
            "media_id": kwargs.pop("media_id", None),
            "watchlist": kwargs.pop("watchlist", None),
        }

        response = self._POST(path, kwargs, payload)
        self._set_attrs_to_values(response)
        return response

favorite(**kwargs)

This method allows you to mark a movie or TV show as a favorite item.

Parameters:

Name Type Description Default
media_type

'movie' | 'tv'

required
media_id

The id of the media.

required
favorite

True (to add) | False (to remove).

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def favorite(self, **kwargs):
    """
    This method allows you to mark a movie or TV show as a favorite item.

    Args:
        media_type: 'movie' | 'tv'
        media_id: The id of the media.
        favorite: True (to add) | False (to remove).

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("favorite")

    payload = {
        "media_type": kwargs.pop("media_type", None),
        "media_id": kwargs.pop("media_id", None),
        "favorite": kwargs.pop("favorite", None),
    }

    response = self._POST(path, kwargs, payload)
    self._set_attrs_to_values(response)
    return response

favorite_movies(**kwargs)

Get the list of your favorite movies.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 code.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def favorite_movies(self, **kwargs):
    """
    Get the list of your favorite movies.

    Args:
        language: (optional) ISO 639-1 code.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("favorite_movies")

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

favorite_tv(**kwargs)

Get the list of your favorite TV shows.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 code.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def favorite_tv(self, **kwargs):
    """
    Get the list of your favorite TV shows.

    Args:
        language: (optional) ISO 639-1 code.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("favorite_tv")

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

info(**kwargs)

Get your account details.

Args:

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def info(self, **kwargs):
    """
    Get your account details.

    Args:

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_path("info")

    response = self._GET(path, kwargs)
    self.id = response["id"]
    self._set_attrs_to_values(response)
    return response

lists(**kwargs)

Get all of the lists created by an account. Will include private lists if you are the owner.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 code.

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def lists(self, **kwargs):
    """
    Get all of the lists created by an account. Will include private lists
    if you are the owner.

    Args:
        language: (optional) ISO 639-1 code.
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("lists")

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

rated_movies(**kwargs)

Get a list of all the movies you have rated.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 value.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def rated_movies(self, **kwargs):
    """
    Get a list of all the movies you have rated.

    Args:
        language: (optional) ISO 639-1 value.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("rated_movies")

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

rated_tv(**kwargs)

Get a list of all the TV shows you have rated.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 value.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
def rated_tv(self, **kwargs):
    """
    Get a list of all the TV shows you have rated.

    Args:
        language: (optional) ISO 639-1 value.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("rated_tv")
    kwargs.update({"session_id": self.session_id})

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

rated_tv_episodes(**kwargs)

Get a list of all the TV episodes you have rated.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 value.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
def rated_tv_episodes(self, **kwargs):
    """
    Get a list of all the TV episodes you have rated.

    Args:
        language: (optional) ISO 639-1 value.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("rated_tv_episodes")
    kwargs.update({"session_id": self.session_id})

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

watchlist(**kwargs)

Add a movie or TV show to your watchlist.

Parameters:

Name Type Description Default
media_type

'movie' | 'tv'

required
media_id

The id of the media.

required
watchlist

True (to add) | False (to remove).

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
def watchlist(self, **kwargs):
    """
    Add a movie or TV show to your watchlist.

    Args:
        media_type: 'movie' | 'tv'
        media_id: The id of the media.
        watchlist: True (to add) | False (to remove).

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("watchlist")
    kwargs.update({"session_id": self.session_id})

    payload = {
        "media_type": kwargs.pop("media_type", None),
        "media_id": kwargs.pop("media_id", None),
        "watchlist": kwargs.pop("watchlist", None),
    }

    response = self._POST(path, kwargs, payload)
    self._set_attrs_to_values(response)
    return response

watchlist_movies(**kwargs)

Get a list of all the movies you have added to your watchlist.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 value.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
def watchlist_movies(self, **kwargs):
    """
    Get a list of all the movies you have added to your watchlist.

    Args:
        language: (optional) ISO 639-1 value.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("watchlist_movies")
    kwargs.update({"session_id": self.session_id})

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response

watchlist_tv(**kwargs)

Get a list of all the TV shows you have added to your watchlist.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 value.

required
sort_by

(optional) Allowed Values: created_at.asc, created_at.desc

required
page

(optional) Minimum 1, maximum 1000, default 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def watchlist_tv(self, **kwargs):
    """
    Get a list of all the TV shows you have added to your watchlist.

    Args:
        language: (optional) ISO 639-1 value.
        sort_by: (optional) Allowed Values: created_at.asc, created_at.desc
        page: (optional) Minimum 1, maximum 1000, default 1.

    Returns:
        A dict representation of the JSON returned from the API.
    """
    path = self._get_id_path("watchlist_tv")
    kwargs.update({"session_id": self.session_id})

    response = self._GET(path, kwargs)
    self._set_attrs_to_values(response)
    return response