File: uploads.py

package info (click to toggle)
python-ytmusicapi 1.10.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,412 kB
  • sloc: python: 4,324; sh: 14; makefile: 12
file content (50 lines) | stat: -rw-r--r-- 1,552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
from ._utils import *
from .songs import parse_song_album, parse_song_artists


def parse_uploaded_items(results):
    songs = []
    for result in results:
        data = result[MRLIR]
        if "menu" not in data:
            continue
        entityId = nav(
            data,
            [
                *MENU_ITEMS,
                -1,
                MNIR,
                "navigationEndpoint",
                "confirmDialogEndpoint",
                "content",
                "confirmDialogRenderer",
                "confirmButton",
                "buttonRenderer",
                "command",
                "musicDeletePrivatelyOwnedEntityCommand",
                "entityId",
            ],
        )
        videoId = nav(data, [*MENU_ITEMS, 0, *MENU_SERVICE])["queueAddEndpoint"]["queueTarget"]["videoId"]

        title = get_item_text(data, 0)
        like = nav(data, MENU_LIKE_STATUS)
        thumbnails = nav(data, THUMBNAILS) if "thumbnail" in data else None
        duration = None
        if "fixedColumns" in data:
            duration = get_fixed_column_item(data, 0)["text"]["runs"][0]["text"]
        song = {
            "entityId": entityId,
            "videoId": videoId,
            "title": title,
            "duration": duration,
            "duration_seconds": parse_duration(duration),
            "artists": parse_song_artists(data, 1),
            "album": parse_song_album(data, 2),
            "likeStatus": like,
            "thumbnails": thumbnails,
        }

        songs.append(song)

    return songs