Support station search results, update localization (#160)
This commit is contained in:
parent
26fa787b06
commit
c5124adbfb
17 changed files with 152 additions and 138 deletions
|
|
@ -10,7 +10,7 @@ This package uses the Linux command line utility xgettext, which you can install
|
|||
Add new translatable texts from code
|
||||
----------------------------------------
|
||||
|
||||
``xgettext -d base -o locales/base.pot ytmusicapi/*.py``
|
||||
``xgettext -d base -o locales/base.pot *.py mixins/*.py parsers/*.py``
|
||||
|
||||
``sed --in-place locales/base.pot --expression=s/CHARSET/UTF-8/``
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,34 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr ""
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr ""
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,37 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr "künstler"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr "playlist"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr "titel"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr "video"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr "sender"
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr "alben"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr "singles"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr "videos"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr "playlists"
|
||||
|
||||
#~ msgid "album"
|
||||
#~ msgstr "album"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,34 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr ""
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr ""
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,37 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr "artista"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr "lista de reproducción"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr "canción"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr "vídeo"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr "emisora"
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr "álbumes"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr "sencillos"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr "vídeos"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr "listas de reproducción"
|
||||
|
||||
#~ msgid "album"
|
||||
#~ msgstr "álbum"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,37 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr "artiste"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr "playlist"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr "titre"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr "vidéo"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr "radio"
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr "albums"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr "singles"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr "vidéos"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr "playlists"
|
||||
|
||||
#~ msgid "album"
|
||||
#~ msgstr "album"
|
||||
msgstr ""
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,37 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr "artista"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr "playlist"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr "brano"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr "video"
|
||||
msgstr ""
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr "stazione"
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr "album"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr "singoli"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr "video"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr "playlist"
|
||||
|
||||
#~ msgid "album"
|
||||
#~ msgstr "album"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,14 +1,14 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
# Translations for ytmusicapi
|
||||
# Copyright (C) 2021 sigma67
|
||||
# This file is distributed under the same license as ytmusicapi
|
||||
# sigma67 <ytmusicapi@gmail.com>
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-21 09:15+0200\n"
|
||||
"POT-Creation-Date: 2021-02-01 14:31+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -17,37 +17,38 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "artist"
|
||||
msgstr "アーティスト"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "playlist"
|
||||
msgstr "プレイリスト"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "song"
|
||||
msgstr "曲"
|
||||
|
||||
#: ytmusicapi/parsers.py:44
|
||||
#: parsers/browsing.py:21
|
||||
msgid "video"
|
||||
msgstr "動画"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:21
|
||||
msgid "station"
|
||||
msgstr "ステーション"
|
||||
|
||||
#: parsers/browsing.py:123
|
||||
msgid "albums"
|
||||
msgstr "アルバム"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "singles"
|
||||
msgstr "シングル"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "videos"
|
||||
msgstr "動画"
|
||||
|
||||
#: ytmusicapi/parsers.py:93
|
||||
#: parsers/browsing.py:123
|
||||
msgid "playlists"
|
||||
msgstr "プレイリスト"
|
||||
|
||||
#~ msgid "album"
|
||||
#~ msgstr "アルバム"
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@ class Parser:
|
|||
search_result = {}
|
||||
if not resultType:
|
||||
resultType = get_item_text(data, 1).lower()
|
||||
result_types = ['artist', 'playlist', 'song', 'video']
|
||||
result_types_local = [_('artist'), _('playlist'), _('song'), _('video')]
|
||||
result_types = ['artist', 'playlist', 'song', 'video', 'station']
|
||||
result_types_local = [
|
||||
_('artist'), _('playlist'),
|
||||
_('song'), _('video'),
|
||||
_('station')
|
||||
]
|
||||
# default to album since it's labeled with multiple values ('Single', 'EP', etc.)
|
||||
if resultType not in result_types_local:
|
||||
resultType = 'album'
|
||||
|
|
@ -27,23 +31,28 @@ class Parser:
|
|||
|
||||
search_result['resultType'] = resultType
|
||||
|
||||
if resultType in ['artist']:
|
||||
if resultType != 'artist':
|
||||
search_result['title'] = get_item_text(data, 0)
|
||||
|
||||
if resultType == 'artist':
|
||||
search_result['artist'] = get_item_text(data, 0)
|
||||
parse_menu_playlists(data, search_result)
|
||||
|
||||
elif resultType in ['album']:
|
||||
search_result['title'] = get_item_text(data, 0)
|
||||
elif resultType == 'album':
|
||||
search_result['type'] = get_item_text(data, 1)
|
||||
search_result['artist'] = get_item_text(data, 1, 2)
|
||||
search_result['year'] = get_item_text(data, 1, 4, True)
|
||||
|
||||
elif resultType in ['playlist']:
|
||||
search_result['title'] = get_item_text(data, 0)
|
||||
elif resultType == 'playlist':
|
||||
search_result['author'] = get_item_text(data, 1, default_offset)
|
||||
search_result['itemCount'] = get_item_text(data, 1,
|
||||
default_offset + 2).split(' ')[0]
|
||||
default_offset + 2).split('\xa0')[0]
|
||||
|
||||
elif resultType in ['song']:
|
||||
elif resultType == 'station':
|
||||
search_result['videoId'] = nav(data, NAVIGATION_VIDEO_ID)
|
||||
search_result['playlistId'] = nav(data, NAVIGATION_PLAYLIST_ID)
|
||||
|
||||
elif resultType == 'song':
|
||||
search_result['duration'] = None
|
||||
if 'menu' in data:
|
||||
toggle_menu = find_object_by_key(nav(data, MENU_ITEMS),
|
||||
|
|
@ -51,12 +60,10 @@ class Parser:
|
|||
if toggle_menu:
|
||||
search_result['feedbackTokens'] = parse_song_menu_tokens(toggle_menu)
|
||||
|
||||
elif resultType in ['video']:
|
||||
elif resultType == 'video':
|
||||
search_result['views'] = None
|
||||
|
||||
elif resultType in ['upload']:
|
||||
search_result['title'] = get_item_text(data, 0)
|
||||
|
||||
elif resultType == 'upload':
|
||||
browse_id = nav(data, NAVIGATION_BROWSE_ID, True)
|
||||
if not browse_id: # song result
|
||||
flex_items = [
|
||||
|
|
@ -97,7 +104,6 @@ class Parser:
|
|||
search_result['videoId'] = nav(
|
||||
data, PLAY_BUTTON + ['playNavigationEndpoint', 'watchEndpoint', 'videoId'],
|
||||
True)
|
||||
search_result['title'] = get_item_text(data, 0)
|
||||
|
||||
song_info = parse_song_runs(get_flex_column_item(data, 1)['text']['runs'])
|
||||
search_result.update(song_info)
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@ def parse_song_runs(runs):
|
|||
for run in runs:
|
||||
text = run['text']
|
||||
if 'navigationEndpoint' in run: # artist or album
|
||||
item = {
|
||||
'name': text,
|
||||
'id': nav(run, NAVIGATION_BROWSE_ID, True)
|
||||
}
|
||||
item = {'name': text, 'id': nav(run, NAVIGATION_BROWSE_ID, True)}
|
||||
|
||||
if item['id'] and item['id'].startswith('MPRE'): # album
|
||||
parsed['album'] = item
|
||||
|
|
@ -33,7 +30,8 @@ def parse_song_runs(runs):
|
|||
parsed['artists'].append(item)
|
||||
|
||||
else:
|
||||
if text.endswith(' views'):
|
||||
# note: YT uses non-breaking space \xa0 to separate number and magnitude
|
||||
if re.match(r"^\d([^ ])* [^ ]*$", text):
|
||||
parsed['views'] = text.split(' ')[0]
|
||||
|
||||
elif re.match(r"^(\d+:)*\d+:\d+$", text):
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
|
|||
Permits both authenticated and non-authenticated requests.
|
||||
Authentication header data must be provided on initialization.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
auth: str = None,
|
||||
user: str = None,
|
||||
|
|
@ -84,11 +83,9 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
|
|||
|
||||
with open(pkg_resources.resource_filename('ytmusicapi', 'context.json')) as json_file:
|
||||
self.context = json.load(json_file)
|
||||
|
||||
|
||||
self.context['context']['client']['hl'] = language
|
||||
supported_languages = [
|
||||
f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')
|
||||
]
|
||||
supported_languages = [f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')]
|
||||
if language not in supported_languages:
|
||||
raise Exception("Language not supported. Supported languages are "
|
||||
', '.join(supported_languages))
|
||||
|
|
@ -96,8 +93,8 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
|
|||
try:
|
||||
locale.setlocale(locale.LC_ALL, self.language)
|
||||
except locale.Error:
|
||||
with suppress(locale.Error):
|
||||
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||
with suppress(locale.Error):
|
||||
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||
self.lang = gettext.translation('base',
|
||||
localedir=pkg_resources.resource_filename(
|
||||
'ytmusicapi', 'locales'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue