kunz Difference between revisions of "Stream Scene Share"

Difference between revisions of "Stream Scene Share"

From kunz
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
<syntaxhighlight lang='python'>
To make it easier to follow along or get caught up, checkpoints of my scene file are be periodically saved and uploaded to a publicly accessible web directory<ref>''[https://hip.johnkunz.com/ttv https://hip.johnkunz.com/ttv]'',</ref>.
import re, urllib
 
url = 'http://hip.johnkunz.com/ttv/'
Whenever a new scene file is shared, a link is posted in Twitch chat. You can use this link to download the file and open it in Houdini.
html = urllib.request.urlopen(url).read()
 
hip = sorted( re.findall(r'href=[\'"]?([^\'" >]+)', html )[5:], reverse=True)[0]
If you'd like to simplify this process, you can use a shelf tool<ref>''[https://www.sidefx.com/docs/houdini/shelf/customize.html sidefx.com/docs/houdini/shelf/customize.html]'', </ref> which calls a script when clicked on. In this case, fetch the most recently shared scene and merge it into your Houdini session.
hou.hipFile.merge(url+hip)
 
</syntaxhighlight>
You can [[:File:twitch.tv.johnkunz.shelf|download the .shelf here]].  Install it by placing it in this location $HOME/houdiniX.x/toolbar/twitch.tv.johnkunz.shelf
 
 
 
== Create the Shelf Tools Yourself ==
If you prefer a more hands on approach, the shelf can be added manually by right-clicking in any empty shelf area and clicking "New Tool...". This will raise a dialog window where the tool's name, label and icon can be defined<ref>''[https://www.sidefx.com/docs/houdini/ref/windows/edittool.html https://www.sidefx.com/docs/houdini/ref/windows/edittool.html]'', </ref>.


<syntaxhighlight lang='python'>
The Python code used in these shelf tools can be found below, Python2 and Python3 are both supported.
import re, urllib2
url = 'http://hip.johnkunz.com/ttv/'
html = urllib2.urlopen(url).read()
hip = sorted( re.findall(r'href=[\'"]?([^\'" >]+)', html )[5:], reverse=True)[0]
hou.hipFile.merge(url+hip)
</syntaxhighlight>


====== Fetch Latest Shared Scene ======
<syntaxhighlight lang='python'>
<syntaxhighlight lang='python'>
import re
import re
url = 'http://hip.johnkunz.com/ttv/'
try:
try:
   import urllib
   import urllib
   html = urllib.request.urlopen(url).read()
   html = urllib.request.urlopen(url).read().decode('utf-8')
except ImportError:
except ImportError:
   import urllib2
   import urllib2
   html = urllib2.urlopen(url).read()
   html = urllib2.urlopen(url).read().decode('utf-8')
hip = sorted( re.findall(r'href=[\'"]?([^\'" >]+)', html )[5:], reverse=True)[0]
hip = sorted( re.findall(r'href=[\'"]?([^\'" >]+)', html )[5:], reverse=True)[0]
hou.hipFile.merge(url+hip)
hou.hipFile.merge(url+hip)
</syntaxhighlight>
</syntaxhighlight>


 
====== Pick from List of Shared Scenes ======
<syntaxhighlight lang='python'>
<syntaxhighlight lang='python'>
import re
import re

Latest revision as of 02:13, 8 October 2021

To make it easier to follow along or get caught up, checkpoints of my scene file are be periodically saved and uploaded to a publicly accessible web directory[1].

Whenever a new scene file is shared, a link is posted in Twitch chat. You can use this link to download the file and open it in Houdini.

If you'd like to simplify this process, you can use a shelf tool[2] which calls a script when clicked on. In this case, fetch the most recently shared scene and merge it into your Houdini session.

You can download the .shelf here. Install it by placing it in this location $HOME/houdiniX.x/toolbar/twitch.tv.johnkunz.shelf


Create the Shelf Tools Yourself

If you prefer a more hands on approach, the shelf can be added manually by right-clicking in any empty shelf area and clicking "New Tool...". This will raise a dialog window where the tool's name, label and icon can be defined[3].

The Python code used in these shelf tools can be found below, Python2 and Python3 are both supported.

Fetch Latest Shared Scene
import re
url = 'http://hip.johnkunz.com/ttv/'
try:
   import urllib
   html = urllib.request.urlopen(url).read().decode('utf-8')
except ImportError:
   import urllib2
   html = urllib2.urlopen(url).read().decode('utf-8')
hip = sorted( re.findall(r'href=[\'"]?([^\'" >]+)', html )[5:], reverse=True)[0]
hou.hipFile.merge(url+hip)
Pick from List of Shared Scenes
import re
# Get list of files
url = 'http://hip.johnkunz.com/ttv/'
try:
   import urllib
   html = urllib.request.urlopen(url).read()
except ImportError:
   import urllib2
   html = urllib2.urlopen(url).read()
hipfile = sorted( re.findall(r'href=[\'"]?([^\'" >]+)', html )[5:], reverse=True)
# Select file from list inside Houdini selection window
mySelection=hou.ui.selectFromList(hipfile, default_choices=(), exclusive=True, message="Twitch.tv/JohnKunz Stream Files", title="Select File", column_header="Choices", num_visible_rows=10, clear_on_cancel=False, width=0, height=0)
# Merge selected file
try: 
    myFile = int(mySelection[0])
    hou.hipFile.merge(url+hipfile[myFile])
    print("File loaded: " + url+hipfile[myFile])
except:
    print("Cancelled: No File Loaded")