taesiri commited on
Commit
6c33596
1 Parent(s): e7ddab0
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -5,7 +5,7 @@ import io
5
  import time
6
  import os
7
  from datetime import datetime, timedelta
8
-
9
 
10
  access_token = os.environ.get("HUGGINGFACE_TOKEN")
11
 
@@ -91,11 +91,19 @@ def get_next_sample():
91
 
92
  sample = next(sample_iterator)
93
  sample_count += 1
94
-
 
95
  post_id = sample["post_id"]
96
  title = sample["title"]
97
  reddit_url = f"https://www.reddit.com/r/PhotoshopRequest/comments/{post_id}"
98
- markdown_text = f"# {title}\n\n[View post on r/PhotoshopRequest]({reddit_url})"
 
 
 
 
 
 
 
99
 
100
  return (
101
  markdown_text,
 
5
  import time
6
  import os
7
  from datetime import datetime, timedelta
8
+ import json
9
 
10
  access_token = os.environ.get("HUGGINGFACE_TOKEN")
11
 
 
91
 
92
  sample = next(sample_iterator)
93
  sample_count += 1
94
+ print(sample)
95
+
96
  post_id = sample["post_id"]
97
  title = sample["title"]
98
  reddit_url = f"https://www.reddit.com/r/PhotoshopRequest/comments/{post_id}"
99
+
100
+ selftext = ""
101
+ try:
102
+ selftext = json.loads(sample["json_data"])["post"]["selftext"]
103
+ except:
104
+ print("No selftext found")
105
+
106
+ markdown_text = f"# {title}\n\n{selftext}\n\n[View post on r/PhotoshopRequest]({reddit_url})"
107
 
108
  return (
109
  markdown_text,