-
Notifications
You must be signed in to change notification settings - Fork 0
/
sub_video.py
90 lines (84 loc) · 2.06 KB
/
sub_video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import requests
import json
url = "https://api.scrolller.com/api/v2/graphql"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "text/plain;charset=UTF-8",
"Origin": "https://scrolller.com",
"Connection": "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"Priority": "u=4",
"TE": "trailers"
}
# GraphQL query
query = """
query SubredditQuery(
$url: String!,
$filter: SubredditPostFilter,
$iterator: String
) {
getSubreddit(url: $url) {
children(
limit: 50,
iterator: $iterator,
filter: $filter,
disabledHosts: null
) {
iterator
items {
__typename
id
url
title
subredditId
subredditTitle
subredditUrl
redditPath
isNsfw
albumUrl
hasAudio
fullLengthSource
gfycatSource
redgifsSource
ownerAvatar
username
displayName
isPaid
tags
isFavorite
mediaSources {
url
width
height
isOptimized
}
blurredMediaSources {
url
width
height
isOptimized
}
}
}
}
}
"""
# Variables for the query
variables = {
"limit": 2,
"url": "/r/animals",
"filter": "VIDEO",
"hostsDown": None
}
data = {
"query": query,
"variables": variables,
"authorization": None,
}
response = requests.post(url, headers=headers, json=data)
print(json.dumps(response.json(), indent=4))