Skip to content

Commit

Permalink
Merge pull request #4 from WolfwithSword/dev
Browse files Browse the repository at this point in the history
Minor QoL updates
  • Loading branch information
WolfwithSword authored Aug 30, 2024
2 parents f3f037c + f72f7a8 commit 1f04680
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ This program supports file/disk based caching. Since this program is used to gen
- A filepath to output the generated html to. Must end with '.html'.
- Can be in a different directory and will automatically copy the lib folder to it if not present.
- **-v | --version**
- Display the current version of TwitchCollabNetwork
- Display the current version of TwitchCollabNetwork
- **-of | --open_file**
- If present, open the HTML output automatically when generation is complete. This uses your system's default program for HTML files.
- **-h | --help**
- Display help message for the program usage

*Examples*

Expand Down
34 changes: 29 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
TwitchCollabNetwork
By: WolfwithSword
Link: https://github.com/WolfwithSword/TwitchCollabNetwork
This utility will create a network map of collabs between Twitch streamers based on tagged usernames in vod titles
"""

import os
import argparse
import sys
Expand All @@ -8,6 +16,7 @@

from datetime import datetime
import logging
import webbrowser

from twitchAPI.twitch import Twitch

Expand All @@ -34,13 +43,21 @@

argv = sys.argv
conf_parser = argparse.ArgumentParser(
description=__doc__, # -h/--help
description="This utility will create a network map of collabs between "
"Twitch streamers based on tagged usernames in vod titles",
epilog="By: WolfwithSword\nLink: https://github.com/WolfwithSword/TwitchCollabNetwork",
formatter_class=argparse.RawDescriptionHelpFormatter,
add_help=False
add_help=True
)
conf_parser.add_argument("-c", "--conf_file", help="Specify config file", metavar="FILE")
conf_parser.add_argument('-o', '--output_file', help="Specify the output file", metavar="FILE")
conf_parser.add_argument('-v', '--version', action='version', version=f'TwitchCollabNetwork Version: {__version__}')
conf_parser.add_argument("-c", "--conf_file", help="Specify config file", metavar="FILE", required=False)
conf_parser.add_argument('-o', '--output_file', help="Specify the output file", metavar="FILE", required=False)
conf_parser.add_argument('-v', '--version', action='version',
version=f'TwitchCollabNetwork Version: {__version__}')
conf_parser.add_argument('-of', '--open_file', help="Automatically open the output file when complete. "
"This will use your system's default program for HTML files",
metavar='', required=False, action=argparse.BooleanOptionalAction)

conf_parser.set_defaults(open_file=False)

args, remaining_argv = conf_parser.parse_known_args()

Expand All @@ -61,6 +78,10 @@
logger.error("No valid config file was found. Please setup a valid config file")
quit()

open_file = False
if args.open_file:
open_file = True

config = TCNConfig()
config.setup(path=config_path)

Expand Down Expand Up @@ -204,6 +225,9 @@ async def twitch_run():
twitch_utils.cache.expire()
twitch_utils.cache.close()

if open_file:
webbrowser.open_new_tab(f"file:///{os.path.abspath(OUTPUT_FILE)}")


def all_done(users: dict, depth: int):
if len(users) >= config.max_connections or depth >= config.max_depth:
Expand Down
10 changes: 9 additions & 1 deletion templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ <h1>{{heading}}</h1>
network.on("click", neighbourhoodHighlight);
{% endif %}

network.on("doubleClick", function(data) {
if (data['nodes'] != undefined) {
var url = "https://twitch.tv/" + data['nodes'][0];
window.open(url, '_blank').focus();
}

});

{% if select_menu %}
network.on("selectNode", neighbourhoodHighlight);
{% endif %}
Expand All @@ -477,7 +485,7 @@ <h1>{{heading}}</h1>
popup.className = 'popup';
popupTimeout = null;
popup.addEventListener('mouseover', function () {
console.log(popup)
//console.log(popup)
if (popupTimeout !== null) {
clearTimeout(popupTimeout);
popupTimeout = null;
Expand Down

0 comments on commit 1f04680

Please sign in to comment.