Repository: streamlink/streamlink

Issue:
Twitch disable reruns
<!-- 
Thanks for filing a feature request!
USE THE TEMPLATE. Otherwise your feature request may be rejected.

First, see the contribution guidelines:
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink

Open a plugin request if you're requesting a new plugin instead of a new feature.

Also check the list of open and closed feature requests:
https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22feature+request%22

Please see the text preview to avoid unnecessary formatting errors.
-->


## Feature Request

<!-- Replace [ ] with [x] in order to check the box -->
- [x] This is a feature request and I have read the contribution guidelines.


### Description

<!-- Explain the feature as clearly as you can. What is it, how would you expect it to work, and what value does it bring to Streamlink? -->
There are disabling hosts (--twitch-disable-hosting), can you also add disabling reruns?

### Expected / Actual behavior

<!-- What do you expect to happen with this new feature, and what is happening currently that does not satisfy this need? -->


### Additional comments, screenshots, etc.



[Love Streamlink? Please consider supporting our collective. Thanks!](https://opencollective.com/streamlink/donate)



Discussion:
I don't think the reruns are actually public like the hosting is since the host is simply a redirect right? Try running with the debug log on and see if it mentions anything about a rerun like it does for a host. If it doesn't there probably isn't anything we can do.
Nothing about reruns in log. Sad :(

Resolving patch:
diff --git a/src/streamlink/plugins/twitch.py b/src/streamlink/plugins/twitch.py
--- a/src/streamlink/plugins/twitch.py
+++ b/src/streamlink/plugins/twitch.py
@@ -374,6 +374,12 @@ class Twitch(Plugin):
                        help="""
         Skip embedded advertisement segments at the beginning or during a stream.
         Will cause these segments to be missing from the stream.
+        """
+                       ),
+        PluginArgument("disable-reruns",
+                       action="store_true",
+                       help="""
+        Do not open the stream if the target channel is currently broadcasting a rerun.
         """
                        ))
 
@@ -697,12 +703,19 @@ def _check_for_host(self):
             self.logger.info("{0} is hosting {1}".format(self.channel, host_info["target_login"]))
             return host_info["target_login"]
 
+    def _check_for_rerun(self):
+        return self.api.streams(self.channel_id)["stream"]["stream_type"] == "rerun"
+
     def _get_hls_streams(self, stream_type="live"):
         self.logger.debug("Getting {0} HLS streams for {1}".format(stream_type, self.channel))
         self._authenticate()
         self._hosted_chain.append(self.channel)
 
         if stream_type == "live":
+            if self._check_for_rerun() and self.options.get("disable_reruns"):
+                self.logger.info("Reruns were disabled by command line option")
+                return {}
+
             hosted_channel = self._check_for_host()
             if hosted_channel and self.options.get("disable_hosting"):
                 self.logger.info("hosting was disabled by command line option")


Test patch: