From 5dc40c1085e19210913947ec0277dbb008c1aed5 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Mar 2020 10:05:22 +0000 Subject: [PATCH 1/3] Added support for gettting image info, height/widtth,type for labels/artist/masters/releases --- speedup/dbconfig.py | 6 +++++- speedup/exporter.py | 10 ++++++++-- speedup/parser.py | 5 ++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/speedup/dbconfig.py b/speedup/dbconfig.py index 2b2ccdc..944d473 100644 --- a/speedup/dbconfig.py +++ b/speedup/dbconfig.py @@ -58,18 +58,21 @@ def connect_db(cfg, set_search_path=False): columns = {table:columns.split() for table, columns in { 'label': 'id name contact_info profile parent_name data_quality', 'label_url': 'label_id url', - 'artist': 'id name realname profile data_quality', + 'label_image': 'label_id type width height', + 'artist': 'id name realname profile data_quality', 'artist_alias': 'artist_id alias_name', 'artist_namevariation': 'artist_id name', 'artist_url': 'artist_id url', 'group_member': 'group_artist_id member_artist_id member_name', + 'artist_image': 'artist_id type width height', 'master': 'id title year main_release data_quality', 'master_artist': 'master_id artist_id artist_name anv position join_string role', 'master_video': 'master_id duration title description uri', 'master_genre': 'master_id genre', 'master_style': 'master_id style', + 'master_image': 'master_id type width height', 'release': 'id title released country notes data_quality master_id', 'release_artist': 'release_id artist_id artist_name extra anv position join_string role tracks', @@ -82,6 +85,7 @@ def connect_db(cfg, set_search_path=False): 'release_identifier': 'release_id description type value', 'release_track': 'release_id sequence position parent title duration', 'release_track_artist': 'release_id track_sequence artist_id artist_name extra anv position join_string role tracks', + 'release_image': 'release_id type width height', }.items()} diff --git a/speedup/exporter.py b/speedup/exporter.py index 783051d..06e7e9e 100755 --- a/speedup/exporter.py +++ b/speedup/exporter.py @@ -146,9 +146,11 @@ def __init__(self, *args, **kwargs): super().__init__('label', *args, **kwargs) main_fields = ['id', 'name', 'contactinfo', 'profile', 'parentLabel', 'data_quality'] + image_fields = ['height', 'width', 'type'] self.actions = ( ('label', _write_entity, [main_fields]), ('label_url', _write_rows, ['urls']), + ('label_image', _write_fields_rows, ['images', image_fields]), ) def validate(self, label): @@ -163,12 +165,14 @@ def __init__(self, *args, **kwargs): super().__init__('artist', *args, **kwargs) main_fields = ['id', 'name', 'realname', 'profile', 'data_quality'] + image_fields = ['height', 'width', 'type'] self.actions = ( ('artist', _write_entity, [main_fields]), ('artist_alias', _write_rows, ['aliases']), ('artist_namevariation', _write_rows, ['namevariations']), ('artist_url', _write_rows, ['urls']), ('group_member', self.write_group_members, None), + ('artist_image', _write_fields_rows, ['images', image_fields]), ) @staticmethod @@ -192,12 +196,14 @@ def __init__(self, *args, **kwargs): main_fields = ['id', 'title', 'year', 'main_release', 'data_quality'] artist_fields = ['id', 'name', 'anv', 'position', 'join', 'role'] video_fields = ['duration', 'title', 'description', 'src'] + image_fields = ['height', 'width', 'type'] self.actions = ( ('master', _write_entity, [main_fields]), ('master_artist', _write_fields_rows, ['artists', artist_fields]), ('master_video', _write_fields_rows, ['videos', video_fields]), ('master_genre', _write_rows, ['genres']), ('master_style', _write_rows, ['styles']), + ('master_image', _write_fields_rows, ['images', image_fields]), ) @@ -214,7 +220,7 @@ def __init__(self, *args, **kwargs): company_fields = [ 'id', 'name', 'entity_type', 'entity_type_name', 'resource_url'] identifier_fields = [ 'description', 'type', 'value'] track_fields = ['sequence', 'position', 'parent', 'title', 'duration'] - + image_fields = ['height', 'width', 'type'] self.artist_fields = [ 'id', 'name', 'extra', 'anv', 'position', 'join', 'role', 'tracks'] self.actions = ( @@ -227,7 +233,7 @@ def __init__(self, *args, **kwargs): ('release_company', _write_fields_rows, ['companies', company_fields]), ('release_identifier', _write_fields_rows, ['identifiers', identifier_fields]), ('release_track', _write_fields_rows, ['tracklist', track_fields]), - + ('release_image', _write_fields_rows, ['images', image_fields]), # Two special operations ('release_artist', self.write_artists, None), ('release_track_artist', self.write_track_artists, None), diff --git a/speedup/parser.py b/speedup/parser.py index 917acd0..c0e46f1 100644 --- a/speedup/parser.py +++ b/speedup/parser.py @@ -87,9 +87,8 @@ def build_entity(self, entity_id, element): 'urls'): setattr(artist, t, list(self.children_text(e))) - # --- images don't seem to bring much information - #elif t in ('images',): - # setattr(artist, t, list(self.element_attributes(e, ImageInfo))) + elif t in ('images',): + setattr(artist, t, list(self.element_attributes(e, ImageInfo))) elif t == 'members': setattr(artist, t, list(self.element_members(e))) From 8fd884b6069025bf7d5b3aca1b4a465e028bc894 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Mar 2020 11:05:54 +0000 Subject: [PATCH 2/3] New Image tables --- speedup/sql/CreateTables.sql | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/speedup/sql/CreateTables.sql b/speedup/sql/CreateTables.sql index cb87f50..ca70550 100644 --- a/speedup/sql/CreateTables.sql +++ b/speedup/sql/CreateTables.sql @@ -26,6 +26,13 @@ CREATE TABLE artist_alias ( alias_artist_id integer ); +CREATE TABLE artist_image ( + artist_id integer NOT NULL, + type text, + width integer, + height integer +); + CREATE TABLE group_member ( group_artist_id integer NOT NULL, member_artist_id integer NOT NULL, @@ -51,6 +58,13 @@ CREATE TABLE label_url ( url text NOT NULL ); +CREATE TABLE label_image ( + label_id integer NOT NULL, + type text, + width integer, + height integer +); + --- masters CREATE TABLE master ( id integer NOT NULL, @@ -92,6 +106,13 @@ CREATE TABLE master_style ( style text ); +CREATE TABLE master_image ( + master_id integer NOT NULL, + type text, + width integer, + height integer +); + --- releases CREATE TABLE release ( id integer NOT NULL, @@ -195,4 +216,12 @@ CREATE TABLE release_company ( entity_type text, entity_type_name text, uri text +); + +CREATE TABLE release_image ( + release_id integer NOT NULL, + type text, + width integer, + height integer ); + From 7670319bccc48fcc05b2153d088cf792204fa5e5 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 10 Mar 2020 12:50:56 +0000 Subject: [PATCH 3/3] fixed order of fields in images --- speedup/exporter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/speedup/exporter.py b/speedup/exporter.py index 06e7e9e..418abb6 100755 --- a/speedup/exporter.py +++ b/speedup/exporter.py @@ -146,7 +146,7 @@ def __init__(self, *args, **kwargs): super().__init__('label', *args, **kwargs) main_fields = ['id', 'name', 'contactinfo', 'profile', 'parentLabel', 'data_quality'] - image_fields = ['height', 'width', 'type'] + image_fields = ['type', 'width', 'height'] self.actions = ( ('label', _write_entity, [main_fields]), ('label_url', _write_rows, ['urls']), @@ -165,7 +165,7 @@ def __init__(self, *args, **kwargs): super().__init__('artist', *args, **kwargs) main_fields = ['id', 'name', 'realname', 'profile', 'data_quality'] - image_fields = ['height', 'width', 'type'] + image_fields = ['type', 'width', 'height'] self.actions = ( ('artist', _write_entity, [main_fields]), ('artist_alias', _write_rows, ['aliases']), @@ -196,7 +196,7 @@ def __init__(self, *args, **kwargs): main_fields = ['id', 'title', 'year', 'main_release', 'data_quality'] artist_fields = ['id', 'name', 'anv', 'position', 'join', 'role'] video_fields = ['duration', 'title', 'description', 'src'] - image_fields = ['height', 'width', 'type'] + image_fields = ['type', 'width', 'height'] self.actions = ( ('master', _write_entity, [main_fields]), ('master_artist', _write_fields_rows, ['artists', artist_fields]), @@ -220,7 +220,7 @@ def __init__(self, *args, **kwargs): company_fields = [ 'id', 'name', 'entity_type', 'entity_type_name', 'resource_url'] identifier_fields = [ 'description', 'type', 'value'] track_fields = ['sequence', 'position', 'parent', 'title', 'duration'] - image_fields = ['height', 'width', 'type'] + image_fields = ['type', 'width', 'height'] self.artist_fields = [ 'id', 'name', 'extra', 'anv', 'position', 'join', 'role', 'tracks'] self.actions = (