Strip HTML from playlist descriptions
This commit is contained in:
parent
4562cfc2e5
commit
fefd96c53a
3 changed files with 20 additions and 5 deletions
|
|
@ -1 +1 @@
|
|||
__version__ = "0.4.0"
|
||||
__version__ = "0.4.1"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
## Static helper methods
|
||||
import re
|
||||
|
||||
# Static helper methods
|
||||
|
||||
|
||||
def parse_songs(results):
|
||||
songs = []
|
||||
|
|
@ -76,4 +79,11 @@ def parse_search_result(data, resultType = None):
|
|||
|
||||
|
||||
def get_item_text(item, index):
|
||||
return item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']['text']['runs'][0]['text']
|
||||
return item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']['text']['runs'][0]['text']
|
||||
|
||||
|
||||
def html_to_txt(html_text):
|
||||
tags = re.findall("<[^>]+>",html_text)
|
||||
for tag in tags:
|
||||
html_text = html_text.replace(tag,'')
|
||||
return html_text
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import requests
|
||||
import json
|
||||
import pkg_resources
|
||||
from ytmusicapi.helpers import parse_songs, parse_search_result
|
||||
from ytmusicapi.helpers import \
|
||||
parse_songs, parse_search_result, html_to_txt
|
||||
|
||||
params = '?alt=json&key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30'
|
||||
base_url = 'https://music.youtube.com/youtubei/v1/'
|
||||
|
|
@ -273,7 +274,11 @@ class YTMusic:
|
|||
:return: ID of the YouTube playlist
|
||||
"""
|
||||
self.__check_auth()
|
||||
body = {'title': title, 'description': description, 'privacyStatus': privacy_status}
|
||||
body = {
|
||||
'title': title,
|
||||
'description': html_to_txt(description), # YT does not allow HTML tags
|
||||
'privacyStatus': privacy_status
|
||||
}
|
||||
endpoint = 'playlist/create'
|
||||
response = self.__send_request(endpoint, body)
|
||||
return response['playlistId']
|
||||
|
|
|
|||
Loading…
Reference in a new issue