From 2db726a31f503fce80d90d243816a2ac5ded86d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Thu, 25 Jan 2024 12:08:46 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A9=B9=20Return=20empty=20result=20ea?= =?UTF-8?q?rly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- okr/scrapers/insta/quintly.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/okr/scrapers/insta/quintly.py b/okr/scrapers/insta/quintly.py index 9c0d927..d06ba64 100644 --- a/okr/scrapers/insta/quintly.py +++ b/okr/scrapers/insta/quintly.py @@ -73,6 +73,9 @@ def get_insta_insights( interval="daily", ) + if df_insta.empty or df_insta_insights.empty: + return pd.DataFrame() + df_insta.time = df_insta.time.str[:10] df_insta.time = df_insta.time.astype("str") df_insta_insights.time = df_insta_insights.time.str[:10] From 1250cc20772e807f4eefab42001a395aa8fd38be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Thu, 25 Jan 2024 12:09:20 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20Prevent=20error=20on=20None?= =?UTF-8?q?=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- okr/scrapers/snapchat_shows/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/okr/scrapers/snapchat_shows/__init__.py b/okr/scrapers/snapchat_shows/__init__.py index 488bfca..8db79ce 100644 --- a/okr/scrapers/snapchat_shows/__init__.py +++ b/okr/scrapers/snapchat_shows/__init__.py @@ -98,7 +98,7 @@ def _scrape_insights_snapchat_show(start_date, snapchat_show): "unique_topsnap_views": row.uniqueTopsnapViews, "topsnap_views": row.topsnapViews, # Convert from percentage to fraction - "attachment_conversion": row.attachmentConversion / 100.0, + "attachment_conversion": (row.attachmentConversion or 0) / 100.0, "attachment_article_views": row.attachmentArticleViews, "attachment_video_views": row.attachmentVideoViews, "screenshots": row.screenshots, From bcbd2acc1f007fb972b64c23c8ddb067a934f337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Thu, 25 Jan 2024 12:09:41 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Add=20new=20source?= =?UTF-8?q?=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...utubetrafficsource_source_type_and_more.py | 78 +++++++++++++++++++ okr/models/youtube.py | 5 ++ 2 files changed, 83 insertions(+) create mode 100644 okr/migrations/0086_alter_youtubetrafficsource_source_type_and_more.py diff --git a/okr/migrations/0086_alter_youtubetrafficsource_source_type_and_more.py b/okr/migrations/0086_alter_youtubetrafficsource_source_type_and_more.py new file mode 100644 index 0000000..564206a --- /dev/null +++ b/okr/migrations/0086_alter_youtubetrafficsource_source_type_and_more.py @@ -0,0 +1,78 @@ +# Generated by Django 4.2.5 on 2024-01-25 11:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("okr", "0085_alter_tiktokdata_videos"), + ] + + operations = [ + migrations.AlterField( + model_name="youtubetrafficsource", + name="source_type", + field=models.CharField( + choices=[ + ("advertising", "Werbung"), + ("annotation", "Annotation"), + ("campaign_card", "Kampagnenkarte"), + ("end_screen", "Endscreen"), + ("ext_url", "Externe URL"), + ("no_link_embedded", "Kein Link (eingebettet)"), + ("no_link_other", "Kein Link (sonstiges)"), + ("notification", "Benachrichtigung"), + ("playlist", "Playlist"), + ("promoted", "Promoted"), + ("related_video", "Related"), + ("shorts", "Shorts"), + ("sound_page", "Soundpage"), + ("subscriber", "Abonnent*in"), + ("yt_channel", "Youtube-Kanal"), + ("yt_other_page", "Sonstige Youtube-Seite"), + ("yt_playlist_page", "Youtube Playlist-Seite"), + ("yt_search", "Youtube-Suche"), + ("hashtags", "Hashtags"), + ("shorts_content_links", "Shorts Content Links"), + ], + max_length=40, + verbose_name="Source Type", + ), + ), + migrations.AlterField( + model_name="youtubevideotrafficsource", + name="source_type", + field=models.CharField( + choices=[ + ("0: Direct or unknown", "Direct or unknown"), + ("1: YouTube advertising", "YouTube advertising"), + ("3: Browse features", "Browse features"), + ("4: YouTube channels", "YouTube channels"), + ("5: YouTube search", "YouTube search"), + ("7: Suggested videos", "Suggested videos"), + ("8: Other YouTube features", "Other YouTube features"), + ("9: External", "External"), + ("11: Video cards and annotations", "Video cards and annotations"), + ("14: Playlists", "Playlists"), + ("17: Notifications", "Notifications"), + ("18: Playlist pages", "Playlist pages"), + ( + "19: Programming from claimed content", + "Programming from claimed content", + ), + ("20: Interactive video endscreen", "Interactive video endscreen"), + ("23: Stories", "Stories"), + ("24: Shorts", "Shorts"), + ("25: Product Pages", "Product Pages"), + ("26: Hashtag Pages", "Hashtag Pages"), + ("27: Sound Pages", "Sound Pages"), + ("28: Live redirect", "Live redirect"), + ("30: Remixed video", "Remixed video"), + ("31: Vertical live feed", "Vertical live feed"), + ("32: Related video", "Related video"), + ], + max_length=40, + verbose_name="Source Type", + ), + ), + ] diff --git a/okr/models/youtube.py b/okr/models/youtube.py index 33782ae..0a91ba6 100644 --- a/okr/models/youtube.py +++ b/okr/models/youtube.py @@ -178,6 +178,7 @@ class SourceType(models.TextChoices): YT_PLAYLIST_PAGE = "yt_playlist_page", "Youtube Playlist-Seite" YT_SEARCH = "yt_search", "Youtube-Suche" HASHTAGS = "hashtags", "Hashtags" + SHORTS_CONTENT_LINKS = "shorts_content_links", "Shorts Content Links" # Not listed in docs, but in data youtube = models.ForeignKey( verbose_name="YouTube-Account", @@ -460,6 +461,10 @@ class SourceType(models.TextChoices): SOURCE_TYPE_25 = "25: Product Pages", "Product Pages" SOURCE_TYPE_26 = "26: Hashtag Pages", "Hashtag Pages" SOURCE_TYPE_27 = "27: Sound Pages", "Sound Pages" + SOURCE_TYPE_28 = "28: Live redirect", "Live redirect" + SOURCE_TYPE_30 = "30: Remixed video", "Remixed video" + SOURCE_TYPE_31 = "31: Vertical live feed", "Vertical live feed" + SOURCE_TYPE_32 = "32: Related video", "Related video" youtube_video = models.ForeignKey( verbose_name="YouTube-Video", From 15e3aeaf53223fe06bd039fedf9ce890c182af8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Thu, 25 Jan 2024 13:54:25 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- okr/models/youtube.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/okr/models/youtube.py b/okr/models/youtube.py index 0a91ba6..5d7a1c8 100644 --- a/okr/models/youtube.py +++ b/okr/models/youtube.py @@ -178,7 +178,10 @@ class SourceType(models.TextChoices): YT_PLAYLIST_PAGE = "yt_playlist_page", "Youtube Playlist-Seite" YT_SEARCH = "yt_search", "Youtube-Suche" HASHTAGS = "hashtags", "Hashtags" - SHORTS_CONTENT_LINKS = "shorts_content_links", "Shorts Content Links" # Not listed in docs, but in data + SHORTS_CONTENT_LINKS = ( + "shorts_content_links", + "Shorts Content Links", + ) # Not listed in docs, but in data youtube = models.ForeignKey( verbose_name="YouTube-Account",