Skip to content

Lists

Bases: TMDB

Lists functionality.

See: https://developers.themoviedb.org/3/lists

Source code in src/tmdb_client_py/account.py
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
class Lists(TMDB):
    """
    Lists functionality.

    See: https://developers.themoviedb.org/3/lists
    """

    BASE_PATH = "list"
    URLS = {
        "info": "/{id}",
        "item_status": "/{id}/item_status",
        "list_create": "",
        "add_item": "/{id}/add_item",
        "remove_item": "/{id}/remove_item",
        "list_clear": "/{id}/clear",
        "list_delete": "/{id}",
    }

    def __init__(self, id=0, session_id=0):
        super().__init__()
        self.id = id
        self.session_id = session_id
        self.list_id: int | None = None

    def info(self, **kwargs):
        """
        Get the details of a list.

        Args:
            language: (optional) ISO 639-1 code.

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

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

    def item_status(self, **kwargs):
        """
        You can use this method to check if a movie has already been added to
        the list.

        Args:
            movie_id: The id of the movie.  Minimum 1.

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

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

    def list_create(self, **kwargs):
        """
        Create a list.

        Args:
            name: Name of the list.
            description: Description of the list.
            language: (optional) ISO 639-1 code.

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

        payload = {
            "name": kwargs.pop("name", None),
            "description": kwargs.pop("description", None),
            "language": kwargs.pop("language", None),
        }

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

    def add_item(self, **kwargs):
        """
        Add a movie to a list.

        Args:
            media_id: A movie id.  Minimum 1.

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

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

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

    def remove_item(self, **kwargs):
        """
        Remove a movie from a list.

        Args:
            media_id: A movie id.  Minimum 1.

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

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

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

    def list_clear(self, **kwargs):
        """
        Clear all of the items from a list.

        Args:
            confirm: True (do it) | False (don't do it)

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

        payload = {}

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

    def list_delete(self, **kwargs):
        """
        Delete a list.

        Args:
            None

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

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

add_item(**kwargs)

Add a movie to a list.

Parameters:

Name Type Description Default
media_id

A movie id. Minimum 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
def add_item(self, **kwargs):
    """
    Add a movie to a list.

    Args:
        media_id: A movie id.  Minimum 1.

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

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

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

info(**kwargs)

Get the details of a list.

Parameters:

Name Type Description Default
language

(optional) ISO 639-1 code.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
def info(self, **kwargs):
    """
    Get the details of a list.

    Args:
        language: (optional) ISO 639-1 code.

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

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

item_status(**kwargs)

You can use this method to check if a movie has already been added to the list.

Parameters:

Name Type Description Default
movie_id

The id of the movie. Minimum 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
def item_status(self, **kwargs):
    """
    You can use this method to check if a movie has already been added to
    the list.

    Args:
        movie_id: The id of the movie.  Minimum 1.

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

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

list_clear(**kwargs)

Clear all of the items from a list.

Parameters:

Name Type Description Default
confirm

True (do it) | False (don't do it)

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
def list_clear(self, **kwargs):
    """
    Clear all of the items from a list.

    Args:
        confirm: True (do it) | False (don't do it)

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

    payload = {}

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

list_create(**kwargs)

Create a list.

Parameters:

Name Type Description Default
name

Name of the list.

required
description

Description of the list.

required
language

(optional) ISO 639-1 code.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
def list_create(self, **kwargs):
    """
    Create a list.

    Args:
        name: Name of the list.
        description: Description of the list.
        language: (optional) ISO 639-1 code.

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

    payload = {
        "name": kwargs.pop("name", None),
        "description": kwargs.pop("description", None),
        "language": kwargs.pop("language", None),
    }

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

list_delete(**kwargs)

Delete a list.

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
def list_delete(self, **kwargs):
    """
    Delete a list.

    Args:
        None

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

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

remove_item(**kwargs)

Remove a movie from a list.

Parameters:

Name Type Description Default
media_id

A movie id. Minimum 1.

required

Returns:

Type Description

A dict representation of the JSON returned from the API.

Source code in src/tmdb_client_py/account.py
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
def remove_item(self, **kwargs):
    """
    Remove a movie from a list.

    Args:
        media_id: A movie id.  Minimum 1.

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

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

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