๐๏ธ wotanii ยท 1 points ยท Posted at 15:33:37 on March 16, 2018 ยท (Permalink)
how do I get the target submission from a crosspost?
(actually I don't need the submission itself, only the video it may refer to)
Minimum example, that should work, but doesn't
import praw
reddit = praw.Reddit(...)
s = reddit.submission('84vepy')
s2 = reddit.submission(url=s.url)
print s2.url
result:
>>> print s2.url
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/praw/models/reddit/base.py", line 31, in __getattr__
self._fetch()
File "/usr/local/lib/python2.7/dist-packages/praw/models/reddit/submission.py", line 149, in _fetch
'sort': self.comment_sort})
File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 367, in get
data = self.request('GET', path, params=params)
File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 472, in request
params=params)
File "/usr/local/lib/python2.7/dist-packages/prawcore/sessions.py", line 181, in request
params=params, url=url)
File "/usr/local/lib/python2.7/dist-packages/prawcore/sessions.py", line 126, in _request_with_retries
raise self.STATUS_EXCEPTIONS[response.status_code](response)
prawcore.exceptions.NotFound: received 404 HTTP response
I think the problem here, is that s.url is https://v.redd.it/5wtgcop6g4m01
[1]', which is apparently no valid input for reddit.submission. But I don't know how to convert that url to a valid submission.[1]
Gprime5 ยท 4 points ยท Posted at 20:44:42 on March 16, 2018 ยท (Permalink)
You can get the cross post with
s.crosspost_parent.๐๏ธ wotanii ยท 3 points ยท Posted at 22:38:08 on March 16, 2018 ยท (Permalink)*
thanks it works.
for anyone, who finds this and has the same problem, you get original submission with:
(the split is required, because crosspost_parent gives the fullname, but the constructors wants just the id. By convention the id is the part after the first underscore)
O_R_I_O_N ยท 1 points ยท Posted at 20:06:50 on February 5, 2023 ยท (Permalink)
thanks op