I Will paste two files below:

playlist.py

from collections import OrderedDict
import logging
import re
from pathlib import Path
import shlex

from mutagen.easyid3 import EasyID3

from .matching import TrackInfo, track_distance, beets_match
from . import spotify
from . import config

log = logging.getLogger(__name__)


def spotlist_to_m3u(spotlist, music_dir):
    music_dir = Path(music_dir)
    files = [p.absolute() for p in music_dir.iterdir()]
    listing = get_sp_data(Path(spotlist))
    id3s = {TrackInfo.from_id3(EasyID3(f)) for f in files}
    m3u = []
    for track in listing:
        for id3 in id3s:
            if track_distance(id3, track) <= 0.3:
                m3u.append(Path(id3.path))
                break
        else:
            log.error("Could not find track %s in %s", str(track), music_dir)
            m3u.append(f"# {track}")

    return "\n".join(
        str(p.relative_to(music_dir.parent.absolute())) if isinstance(p, Path) else p
        for p in m3u
    )


def get_sp_data(spotlist):
    listing = [re.split(r"\s,", l) for l in Path(spotlist).read_text().splitlines()]
    tracks = []
    for t in listing:
        tracks.append(TrackInfo(*t))
    return tracks


def create_m3u_from_info(track_infos, output: Path, url=None):
    "From a mapping of TrackInfo -> beetsLibraryItems, create a m3u playlist"
    log.info("Writing m3u file to %s.", output)
    with open(output, "wb") as fout:
        if url:
            fout.write("# {}\n".format(url).encode("utf8"))
        for track, item in track_infos.items():
            try:
                fout.write(item.path)
            except AttributeError:
                if isinstance(track, str):
                    fout.write(track.encode("utf8"))
                elif isinstance(track, TrackInfo):
                    fout.write(
                        b"# TrackInfo(json='''%s''')" % track.json().encode("utf8")
                    )
            fout.write(b"\n")


def create_info_from_m3u(m3u: Path, lib):
    "Given an m3u, track_info:beets_match dictionary"
    m3u = Path(m3u)
    matches = OrderedDict()
    for line in m3u.read_text().splitlines():
        if line.startswith("# TrackInfo"):
            info = parse_track_info_string(line)
            matches[info] = None
        elif line.startswith("#"):
            matches[line] = None
            continue
        else:
            item = lib.items(shlex.quote("path:" + line)).get()
            if item is None:
                log.error("Could not find item at path %s", line)
                continue
            matches[item] = item
    return matches


async def parse_playlist(argument, library):
    "Given a path or spotify uri return playlist_name, track_info"
    spotify_id = parse_spotfiy_id(argument)
    if spotify_id:
        log.info("Fetching playlist %s from spotify.", spotify_id)
        return await spotify.fetch_play_list_data(spotify_id)
    f = Path(argument)
    if not f.exists():
        log.error("Could not find the file %s", f)
        raise FileNotFoundError(f)
    if f.suffix in [".m3u", ".m3u8"]:
        log.info("Reading in m3u file %s.", f.stem)
        return f.stem, create_info_from_m3u(f, lib=library)
    log.info("Reading in csv file %s.", f.stem)
    return f.stem, get_sp_data(f)


async def make_missing_spotify_playlist(title, trackinfos):
    try:
        assert all(hasattr(t, "spotify_id") for t in trackinfos)
    except AssertionError:
        log.error("Not all tracks have a spotify id, cannot create a spotify playlist.")
        return
    ids = (t.spotify_id for t in trackinfos)
    description = (
        f"A playlist of songs from the {title} playlist "
        "that you do not have in your beets library."
    )
    try:
        location = await spotify.create_new_playlist(
            title + " (missing tracks)", ids, description
        )
    except Exception as e:
        log.error("Could not create spotify playlist!")
        log.debug("Stack Trace:", exc_info=True)
        if isinstance(e, spotify.SpotifyError):
            try:
                if e.json["error"]["status"] == 403:
                    token_file = Path(config.config_dir()) / "spotify_token.json"
                    log.error(
                        (
                            "[RED]list does not have sufficient permissions."
                            " Try deleting %s to reauthorize"
                        ),
                        token_file,
                    )
            except KeyError:
                pass
        return
    print(
        f"created playlist of missing tracks at : https://open.spotify.com/playlist/{location}"
    )
    playlist_url="https://open.spotify.com/playlist/"+location
    import subprocess
    #subprocess.call(['sh','/home/janis/spotdl/spotify-dl.sh', playlist_url])
    #subprocess.call(['python','/home/janis/mp3_metadata/mp3_metadata_claude.py', '/home/janis/plex/media/music/tonwelleMusic/Inbox'])
    #subprocess.call(['beet', 'import', '-m', '-A', '/home/janis/plex/media/music/tonwelleMusic/Inbox'])
def parse_spotfiy_id(address):
    "Return the playlist id if it's a spotify playlist. Otherwise return False"
    match = re.match(r".*spotify.*[:/]playlist[:/]([\w\d]+)", address)
    return match.group(1) if match else None


def parse_track_info_string(line):
    # Try extracting json first
    m = re.search(r"json=[\'|\"]{1,3}(.+?)[\'\"]{1,3}\)$", line)
    if m:
        return TrackInfo(json=m.group(1))
    # Old (incorrect) style. Must keep for compatibility
    kwargs = {}
    line = re.search(r"TrackInfo\((.*)\)", line).group(1)
    args = re.findall(r"[\w|_].+?\=[\',\"]?.*?[\d|\'|\"]\,", line)
    args = [a.strip("'\",") for a in args]
    for a in args:
        k, v = a.split("=")
        if v == "None":
            kwargs[k] = None
        elif re.match(r"\d+", v):
            kwargs[k] = float(v)
        else:
            kwargs[k] = v.strip("'\"")
    return TrackInfo(**kwargs)


spotify.py

import aiohttp
import asyncio
import base64
import time
import json
import logging
import re
import pprint
from cryptography import fernet
from urllib.parse import urlencode
from pathlib import Path
import os

from beets.util import sanitize_path

from . import config
from . import ui
from . import matching
from . import utils

log = logging.getLogger(__name__)

KEY = b"vWaggFkc0KRH_19qhyjhduPIF8vq6eFrUGngiUUahdc="
CODE = (
    b"gAAAAABdm60DpX-pHvoEtf2JbZmK6SQYjLE2MwK25LJT1JBiJcol7KHaOgnHnwYx8Z8DQR1igOnXD"
    b"B-BhFGuD0dXAHvJRBMpbyR1m6KfedbSoFh4n9AKt5uY8yoAx3BeoPlFqVR3I3Exfbn5vUP9jAH7jamecRMSSPc"
    b"Y-yL5iZyQ_5rrkOUZ2ls="
)
frn = fernet.Fernet(KEY)
AUTH_HEADER = frn.decrypt(CODE)
CLIENT_ID, _ = AUTH_HEADER.split(b":")
AUTH_HEADER = {
    "Authorization": "Basic " + base64.b64encode(AUTH_HEADER).decode("ascii")
}
AUTH_URL = "https://accounts.spotify.com/authorize"
TOKEN_URL = "https://accounts.spotify.com/api/token"


class SpotifyError(Exception):
    def __init__(self, *args, json={}):
        self.json = json
        super().__init__(args)


async def fetch_play_list_data(playlist_id, token=None):
    "given a uri or playlist id, return a list of TrackInfo objects"
    if token is None:
        token = SpotifyAccessToken()
        await token.ensure_valid()

    url = f"https://api.spotify.com/v1/playlists/{playlist_id}"
    data = {"next": url}
    name = playlist_id
    tracks = []
    async with aiohttp.ClientSession(headers=token.auth_header) as session:
        while data["next"]:
            async with session.get(data["next"]) as resp:
                if resp.status == 429:  # Rate limit exceded
                    await asyncio.sleep(resp.headers["Retry-After"] + 1)
                    continue
                json = await resp.json()
            try:  # First iteration
                #  pprint.pprint(json)
                data = json["tracks"]
                name = json["name"]
                #pprint.pprint(json["artists"])
            except KeyError:  # more than 100 data
                log.debug("Fetching more playlist tracks from Spotify.")
                data = json
            try:
                tracks.extend(
                    matching.TrackInfo.from_spotify(t)
                    for t in data["items"]
                    if t["track"] is not None
                )
            except matching.MatchingError as e:
                pprint.pprint(e.data)
                raise
            log.debug("%s tracks Fetched from playlist.", len(tracks))
    name = re.sub(r"[\\/]", "_", name)
    name = sanitize_path(name)
    return name, tracks


async def fetch_track_data(*ids, token=None):
    "Get track data from given spotify trackids"
    if token is None:
        token = SpotifyAccessToken()
        await token.ensure_valid()

    url = "https://api.spotify.com/v1/tracks"
    data = []
    async with aiohttp.ClientSession(headers=token.auth_header) as session:
        for tracks in utils.chunk(ids, 50):
            params = {"ids": ",".join(tracks)}
            while True:
                async with session.get(url, params=params) as resp:
                    if resp.status == 429:
                        log.debug("Rate limit exceded, waiting...")
                        await asyncio.sleep(resp.headers["Retry-After"] + 1)
                        continue
                    json = await resp.json()
                    data.extend(json["tracks"])
                    break
    return data


async def create_new_playlist(title, ids, description=None, token=None):
    'create a new playlist with "title" containing the the track ids'
    if token is None:
        token = SpotifyAccessToken()
        await token.ensure_valid()

    user_id = await get_user_id()
    url = f"https://api.spotify.com/v1/users/{user_id}/playlists"
    async with aiohttp.ClientSession(headers=token.auth_header) as session:
        params = {"user_id": user_id, "Content-Type": "application/json"}
        data = {
            "name": title,
            "public": False,
        }
        if description:
            data["description"] = description
        async with session.post(url, params=params, json=data) as resp:
            json = await resp.json()
            log.error(resp.status)
            if resp.status not in (201, 200):
                log.debug("Couldn't create playlist")
                log.debug("Spotify response: %s", json)
                raise SpotifyError(json=json)
            playlist_id = json["id"]
            log.debug("Created new spotify playlist with id %s", playlist_id)

        url = f"https://api.spotify.com/v1/playlists/{playlist_id}/tracks"
        params = {"Content-Type": "application/json"}
        for tracks in utils.chunk(ids, 100):
            uris = [f"spotify:track:{i}" for i in tracks]
            data = {"uris": uris}
            while True:
                async with session.post(url, params=params, json=data) as resp:
                    if resp.status == 429:
                        log.debug("Rate limit exceded, waiting...")
                        await asyncio.sleep(resp.headers["Retry-After"] + 1)
                        continue
                    if resp.status != 201 :
                        log.debug("Unexpected response code: %d", resp.status)
                        json = await resp.json()
                        log.debug("Response body: %s", json)
                        raise SpotifyError(json=json)
                    break
    return playlist_id


async def get_user_id(token=None):
    "get the spotify_id of the current user"
    if token is None:
        token = SpotifyAccessToken()
        await token.ensure_valid()
    url = "https://api.spotify.com/v1/me"
    async with aiohttp.ClientSession(headers=token.auth_header) as session:
        async with session.get(url) as resp:
            while True:
                async with session.get(url) as resp:
                    if resp.status == 429:
                        log.debug("Rate limit exceded, waiting...")
                        await asyncio.sleep(resp.headers["Retry-After"] + 1)
                        continue
                    json = await resp.json()
                    return json["id"]


def generate_auth_url():
    data = {
        "client_id": CLIENT_ID,
        "response_type": "code",
        "redirect_uri": "http://localhost/",
        "scope": "playlist-modify-private",
    }
    return "?".join((AUTH_URL, urlencode(data)))


def parse_resp_code(url):
    return url.split("?code=")[1].split("&")[0]


class SpotifyAccessToken:
    def __init__(self):
        self.token_info = None
        config_dir = Path(config.config_dir())
        try:
            with open(config_dir / "spotify_token.json") as fin:
                self.token_info = json.load(fin)
        except (FileNotFoundError, json.JSONDecodeError) as e:
            log.debug("Could not load spotify token because of %s", e, exc_info=True)

    @property
    def is_valid(self):
        now = time.time()
        try:
            if self.token_info["expires_at"] - now > 60:
                return True
        except (TypeError, KeyError):
            pass
        return False

    @property
    def auth_header(self):
        assert self.is_valid
        return {"Authorization": "Bearer %s" % self.token_info["access_token"]}

    def save(self):
        config_dir = Path(config.config_dir())
        with open(config_dir / "spotify_token.json", "w") as fout:
            json.dump(self.token_info, fout)
            log.debug("Saved new spotify auth token to %s", fout.name)

    async def ensure_valid(self):
        if self.is_valid:
            return
        if not self.token_info:
            await self.gen_new()
            return
        await self.refresh()

    async def gen_new(self):
        log.debug("Attempting to generate new auth token.")
        redirect = ui.get_spotify_auth_code(generate_auth_url())
        code = parse_resp_code(redirect)

        data = {
            "redirect_uri": "http://localhost/",
            "code": code,
            "scope": ["playlist-modify-private"],
            "grant_type": "authorization_code",
        }
        async with aiohttp.ClientSession() as session:
            async with session.post(TOKEN_URL, headers=AUTH_HEADER, data=data) as resp:
                token_info = await resp.json()
                if resp.status != 200:
                    raise ValueError(resp.reason, token_info)
        token_info["expires_at"] = int(time.time()) + token_info["expires_in"]
        self.token_info = token_info
        self.save()
        return token_info

    async def refresh(self):
        data = {
            "refresh_token": self.token_info["refresh_token"],
            "grant_type": "refresh_token",
        }
        async with aiohttp.ClientSession() as session:
            async with session.post(TOKEN_URL, headers=AUTH_HEADER, data=data) as resp:
                token_info = await resp.json()
        token_info["expires_at"] = int(time.time()) + token_info["expires_in"]
        self.token_info.update(token_info)
        log.debug("Spotify token successfully refreshed.")
        self.save()
        return token_info


Can you modify the code, so that it retrieves all tracks of the user via the "Get userrs Tracks" endpoint of the spotify api instead of a playlist. Keep in mind that the "Get userrs Tracks" endpoint may respond with slightly different data than the playlist endpoint. Double check, that the same output as before is returned to all the funtions in the code because you only know part of the whole source code.  keep the names of all funtions to make the code 100% compatible to the rest of the source code not pasted here.