Created
October 21, 2019 21:03
-
-
Save valerierx/d14b0336ff43e4995b4fd506a7de9690 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/src/CbTypes.c b/src/CbTypes.c | |
index 4239c549..8b1b5e30 100644 | |
--- a/src/CbTypes.c | |
+++ b/src/CbTypes.c | |
@@ -207,6 +207,8 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
int max_entities; | |
gboolean direct_duplicate = FALSE; | |
+ g_debug("XXX Parsing entities for tweet %ld", t->id); | |
+ | |
if (json_object_has_member (status, "extended_tweet")) | |
extended_obj = json_object_get_object_member (status, "extended_tweet"); | |
@@ -215,11 +217,13 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
hashtags = json_object_get_array_member (entities, "hashtags"); | |
user_mentions = json_object_get_array_member (entities, "user_mentions"); | |
media_count = json_object_get_member_size (entities, "media"); | |
+ g_debug("XXX media_count = %d", media_count); | |
if (json_object_has_member (status, "extended_entities")) | |
media_count += json_object_get_member_size (json_object_get_object_member (status, "extended_entities"), | |
"media"); | |
+ g_debug("XXX media_count with extended = %d", media_count); | |
if (json_object_has_member (status, "in_reply_to_status_id") && | |
!json_object_get_null_member (status, "in_reply_to_status_id")) | |
@@ -281,6 +285,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
json_array_get_length (user_mentions) - non_reply_mentions + | |
media_count; | |
media_count += (int)json_array_get_length (urls); | |
+ g_debug("XXX media_count with = %d", media_count); | |
t->medias = g_new0 (CbMedia*, media_count); | |
@@ -346,6 +351,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
/* MEDIA */ | |
if (json_object_has_member (entities, "media")) | |
{ | |
+ g_debug("XXX Has media element"); | |
JsonArray *medias = json_object_get_array_member (entities, "media"); | |
for (i = 0, p = json_array_get_length (medias); i < p; i ++) | |
@@ -353,6 +359,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
JsonObject *url = json_node_get_object (json_array_get_element (medias, i)); | |
JsonArray *indices = json_object_get_array_member (url, "indices"); | |
char *url_str = cb_utils_escape_ampersands (json_object_get_string_member (url, "url")); | |
+ g_debug("XXX Media URL %d of %d is %s", i, p, url_str); | |
int k; | |
gboolean duplicate = FALSE; | |
@@ -362,6 +369,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
const char *target = t->entities[k].target; | |
if (target != NULL && strcmp (target, url_str) == 0) | |
{ | |
+ g_debug("XXX Found duplicate URL at %d", k); | |
duplicate = TRUE; | |
break; | |
} | |
@@ -387,12 +395,14 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
contain all the attached media, so parse both the same way... */ | |
if (json_object_has_member (entities, "media")) | |
{ | |
+ g_debug("XXX Has media element for media array"); | |
media_arrays[n_media_arrays] = json_object_get_array_member (entities, "media"); | |
n_media_arrays ++; | |
} | |
if (json_object_has_member (status, "extended_entities")) | |
{ | |
+ g_debug("XXX Has extended_entities element for media array"); | |
media_arrays[n_media_arrays] = json_object_get_array_member (json_object_get_object_member (status, | |
"extended_entities"), | |
"media"); | |
@@ -402,11 +412,13 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
for (i = 0; i < n_media_arrays; i ++) | |
{ | |
+ g_debug("XXX Checking media array %d", i); | |
guint x, k; | |
for (x = 0, p = json_array_get_length (media_arrays[i]); x < p; x ++) | |
{ | |
JsonObject *media_obj = json_node_get_object (json_array_get_element (media_arrays[i], x)); | |
const char *media_type = json_object_get_string_member (media_obj, "type"); | |
+ g_debug("XXX Media %d of %d is %s", x, p, media_type); | |
if (strcmp (media_type, "photo") == 0) | |
{ | |
@@ -420,6 +432,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
{ | |
if (t->medias[k] != NULL && strcmp (t->medias[k]->url, url) == 0) | |
{ | |
+ g_debug("XXX Found duplicate image at %d", k); | |
dup = TRUE; | |
break; | |
} | |
@@ -430,6 +443,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
if (is_media_candidate (url)) | |
{ | |
+ g_debug("XXX Found media candidate %d", t->n_medias); | |
t->medias[t->n_medias] = cb_media_new (); | |
t->medias[t->n_medias]->type = CB_MEDIA_TYPE_IMAGE; | |
t->medias[t->n_medias]->url = g_strdup (url); | |
@@ -472,13 +486,16 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
JsonObject *v = json_node_get_object (json_array_get_element (variants, k)); | |
if (strcmp (json_object_get_string_member (v, "content_type"), "application/x-mpegURL") == 0) | |
{ | |
+ g_debug("XXX Found application/x-mpegURL variant"); | |
variant = v; | |
break; | |
} | |
} | |
- if (variant == NULL && json_array_get_length (variants) > 0) | |
+ if (variant == NULL && json_array_get_length (variants) > 0) { | |
+ g_debug("XXX Using first video variant"); | |
variant = json_node_get_object (json_array_get_element (variants, 0)); | |
+ } | |
if (variant != NULL) | |
{ | |
@@ -495,6 +512,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
t->medias[k]->type == CB_MEDIA_TYPE_IMAGE && | |
strcmp (t->medias[k]->url, thumb_url) == 0) | |
{ | |
+ g_debug("XXX Replacing thumbnail at %d with video", k); | |
/* Replace this media */ | |
g_object_unref (t->medias[k]); | |
n_media = k; | |
@@ -522,6 +540,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
if (t->n_medias == 0) | |
{ | |
+ g_debug("XXX Found no media - checking expanded URLs"); | |
for (i = 0, p = json_array_get_length (urls); i < p; i ++) | |
{ | |
JsonObject *url = json_node_get_object (json_array_get_element (urls, i)); | |
@@ -529,6 +548,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
if (is_media_candidate (expanded_url)) | |
{ | |
+ g_debug("XXX Adding %s as media", expanded_url); | |
t->medias[t->n_medias] = cb_media_new (); | |
t->medias[t->n_medias]->url = g_strdup (expanded_url); | |
t->medias[t->n_medias]->type = cb_media_type_from_url (expanded_url); | |
@@ -543,6 +563,7 @@ cb_mini_tweet_parse_entities (CbMiniTweet *t, | |
g_debug ("Wasted entities: %d", max_entities - t->n_entities); | |
g_debug ("Wasted media : %d", media_count - t->n_medias); | |
#endif | |
+ g_debug("XXX Found %d media in total", t->n_medias); | |
if (t->n_medias > 0) | |
cb_media_downloader_load_all (cb_media_downloader_get_default (), t); | |
diff --git a/src/list/TweetListEntry.vala b/src/list/TweetListEntry.vala | |
index 39efa30b..ada586ce 100644 | |
--- a/src/list/TweetListEntry.vala | |
+++ b/src/list/TweetListEntry.vala | |
@@ -206,6 +206,7 @@ public class TweetListEntry : Cb.TwitterItem, Gtk.ListBoxRow { | |
Gtk.Widget w = media_stack != null ? ((Gtk.Widget)media_stack) : ((Gtk.Widget)mm_widget); | |
this.grid.attach (w, 1, 3, 6, 1); | |
mm_widget.restrict_height = restrict_height; | |
+ debug("XXX Setting %d tweet media for %lld", tweet.get_medias ().length, tweet.id); | |
mm_widget.set_all_media (tweet.get_medias ()); | |
mm_widget.media_clicked.connect (media_clicked_cb); | |
mm_widget.media_invalid.connect (media_invalid_cb); | |
@@ -227,6 +228,7 @@ public class TweetListEntry : Cb.TwitterItem, Gtk.ListBoxRow { | |
Gtk.Widget w = quoted_media_stack != null ? ((Gtk.Widget)quoted_media_stack) : ((Gtk.Widget)quoted_mm_widget); | |
this.quote_grid.attach (w, 0, 3, 3, 1); | |
quoted_mm_widget.restrict_height = restrict_height; | |
+ debug("XXX Setting %d quote tweet media for %lld (%lld)", tweet.get_quoted_medias ().length, tweet.id, tweet.quoted_tweet.id); | |
quoted_mm_widget.set_all_media (tweet.get_quoted_medias ()); | |
quoted_mm_widget.media_clicked.connect (quoted_media_clicked_cb); | |
quoted_mm_widget.media_invalid.connect (quoted_media_invalid_cb); | |
diff --git a/src/util/Utils.vala b/src/util/Utils.vala | |
index 280619ae..07dbb172 100644 | |
--- a/src/util/Utils.vala | |
+++ b/src/util/Utils.vala | |
@@ -365,7 +365,6 @@ namespace Utils { | |
public bool usable_json_value (Json.Object node, string value_name) { | |
if (!node.has_member (value_name)) | |
return false; | |
- debug("usable_json_value"); | |
return !node.get_null_member (value_name); | |
} | |
diff --git a/src/widgets/MultiMediaWidget.vala b/src/widgets/MultiMediaWidget.vala | |
index c33a165b..bdb7f3d7 100644 | |
--- a/src/widgets/MultiMediaWidget.vala | |
+++ b/src/widgets/MultiMediaWidget.vala | |
@@ -32,6 +32,7 @@ public class MultiMediaWidget : Gtk.Box { | |
} | |
public void set_all_media (Cb.Media[] medias) { | |
+ debug("XXX Setting %d medias", medias.length); | |
this.remove_all (); | |
this.media_buttons = new MediaButton[medias.length]; | |
this.media_count = medias.length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment