ihabunek / twitch-dl

CLI tool for downloading videos from Twitch.
GNU General Public License v3.0
661 stars 84 forks source link

Plz help me to set timeout to None #143

Open jarvis08 opened 10 months ago

jarvis08 commented 10 months ago

Hello. I'm trying to see how many clips are existing at target streamer's channel. The twitch-dl uses get_channel_clips func in twitch.py to get the list, but the result says gql timeout. (I guess the streamer has lots of clips..)

I gave timeout=None option to httpx post, but the same error occurs, and there for I think I have to give the timeout option to the query string. However, I do not know how the query string work, so I'm stuck at this moment.

plz help me.

jarvis08 commented 10 months ago

def get_channel_clips(channel_id, period, limit, after=None): """ List channel clips.

At the time of writing this:
* filtering by game name returns an error
* sorting by anything but VIEWS_DESC or TRENDING returns an error
* sorting by VIEWS_DESC and TRENDING returns the same results
* there is no totalCount
"""
query = """
{{
  user(login: "{channel_id}") {{
    clips(first: {limit}, after: "{after}", criteria: {{ period: {period}, sort: VIEWS_DESC }}) {{
      pageInfo {{
        hasNextPage
        hasPreviousPage
      }}
      edges {{
        cursor
        node {{
          {fields}
        }}
      }}
    }}
  }}
}}
"""

query = query.format(
    channel_id=channel_id,
    after=after if after else "",
    limit=limit,
    period=period.upper(),
    fields=CLIP_FIELDS
)

response = gql_query(query)
user = response["data"]["user"]
if not user:
    raise ConsoleError("Channel {} not found".format(channel_id))

return response["data"]["user"]["clips"]