Last active
November 1, 2018 22:37
-
-
Save probablykasper/1727f28da311699c54eb8fd5e580dd29 to your computer and use it in GitHub Desktop.
My user_md_parser.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user_md_parser(smart_md, md, video_info, url_info): | |
# smart_md: | |
# Metadata object created by vidl. Metadata objects can have these properties: | |
# - title | |
# - artist | |
# - album | |
# - album_artist | |
# - track_number | |
# - track_count | |
# - year | |
# - comment | |
# - lyrics | |
# - composer | |
# md: | |
# Same as "md", except this will never include smart metadata (artist/title | |
# parsed from title). | |
# video_info: | |
# Object containing metadata from youtube-dl about the current video. | |
# playlist_info: | |
# An object containing playlist metadata from youtube-dl. | |
# If the URL isn't a playlist, playlist_info is the same as video_info. | |
# If the URL is a playlist, it has an "entries" property with video_info objects. | |
# callback: Callback function. Takes a metadata object as argument. | |
# | |
# example: | |
# # This example cheks if vidl has detected title and artist metadata. If the | |
# # title includes "[NCS Release]", it will set the comment metadata to "NCS". | |
# if 'title' in md and 'artist' in md: | |
# if '[NCS Release]' in md['title']: | |
# md['comment'] = 'NCS' | |
import copy | |
final_md = copy.deepcopy(smart_md) | |
if 'title' in md and 'artist' in md: | |
def remove_if_title_endswith(title_end): | |
if md['title'].endswith(title_end): | |
final_md['title'] = final_md['title'].replace(title_end, '') | |
def comment_if_artist_is(artist, comment=None): | |
if not comment: comment = artist | |
if md['artist'] == artist: | |
final_md['comment'] = comment | |
soundcloud = url_info['extractor'] == 'soundcloud' | |
youtube = url_info['extractor'] == 'youtube' | |
remove_if_title_endswith(' [NCS Release]') | |
remove_if_title_endswith(' [NCS Official Video]') | |
remove_if_title_endswith(' [NCS Lyric Video]') | |
remove_if_title_endswith(' [Monstercat Release]') | |
remove_if_title_endswith(' [Monstercat Official Music Video]') | |
remove_if_title_endswith(' [Monstercat Lyric Video]') | |
if not youtube: comment_if_artist_is(artist='Monstercat') | |
if youtube: comment_if_artist_is(artist='Monstercat: Uncaged', comment='Monstercat') | |
if youtube: comment_if_artist_is(artist='Monstercat: Instinct', comment='Monstercat') | |
comment_if_artist_is('Trap Nation') | |
if soundcloud: comment_if_artist_is('Trap Nation Records', 'Trap Nation') | |
comment_if_artist_is(artist='Chill Nation') | |
comment_if_artist_is(artist='Bass Nation') | |
comment_if_artist_is(artist='House Nation') | |
comment_if_artist_is(artist='Rap Nation') | |
comment_if_artist_is(artist='Indie Nation') | |
comment_if_artist_is(artist='R&B Nation') | |
comment_if_artist_is(artist='Lowly', comment='Lowly.') | |
comment_if_artist_is('UKF Drum & Bass') | |
comment_if_artist_is('UKF Dubstep') | |
if not soundcloud: comment_if_artist_is(artist='DubstepGutter') | |
if soundcloud: comment_if_artist_is(artist='DSG', comment='DubstepGutter') | |
comment_if_artist_is(artist='CloudKid') | |
comment_if_artist_is(artist='Clown Music') | |
comment_if_artist_is(artist='HeroicMusic') | |
comment_if_artist_is(artist='MrSuicideSheep') | |
comment_if_artist_is(artist='Trap City') | |
return final_md |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment