Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Regex for Rainmeter

Posted on 2014-10-21
Medium Priority
Last Modified: 2014-10-21
Can someone please help with the Regexp below. I am using the webparser plugin in Rainmeter to pull now watching data from plex.

RegExp=(?siU)<Part container=.*\\(.*)".*<User id="1".*title="(.*)"

01=> Videos\TV Shows\24\Season 07\24 - 7x04 - Day 7 1100 A.M. - 1200 P.M
02=> chaoticmaster

I would like it to be:

 01=>24 - 7x04 - Day 7 1100 A.M. - 1200 P.M
 02=> chaoticmaster

Also is there anyway to get the code to the Regex based on the number of users.

So results would be:

01=> 24 - 7x04 - Day 7 1100 A.M. - 1200 P.M
02=> chaoticmaster
03=> Airplane II (1982)
04=> johndoe

I captured the user count information in a previous parse called ConnectedUsers

<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="2">
<Video addedAt="1396456678" art="/library/metadata/832/art/1402972060" contentRating="TV-14" duration="2592548" grandparentKey="/library/metadata/832" grandparentRatingKey="832" grandparentTheme="/library/metadata/832/theme/1402972060" grandparentThumb="/library/metadata/832/thumb/1402972060" grandparentTitle="24" guid="com.plexapp.agents.thetvdb://76290/7/4?lang=en" index="4" key="/library/metadata/34109" librarySectionID="2" originallyAvailableAt="2009-01-12" parentIndex="7" parentKey="/library/metadata/983" parentRatingKey="983" parentThumb="/library/metadata/983/thumb/1377743587" rating="7.4" ratingKey="34109" sessionKey="12" summary="Buchanan takes Jack to &quot;CTU&quot;, a secret hideout where he and Chloe had been working with Tony to uncover the conspiracy within the US government. Tony had been undercover with the terrorists aiding Juma to discover the moles. Jack agrees to help get Tony back in play by joining Emerson&apos;s crew himself.&#xA;&#xA;Taylor is forced to meet with Matobo to inform him that she may be required to withdraw her forces from Sangala to protect American lives. Her Chief of Staff Ethan Kanin agrees with this decision, but Taylor is not yet convinced.&#xA;&#xA;Henry meets with Samantha, Roger&apos;s former girlfriend, who tells him that Roger was indeed murdered and provides him with proof." thumb="/library/metadata/34109/thumb/1396456712" title="Day 7: 11:00 A.M. - 12:00 P.M." type="episode" updatedAt="1396456712" viewOffset="2590" year="2009">
<Media aspectRatio="1.78" audioChannels="2" audioCodec="mp3" bitrate="1132" container="avi" duration="2592548" height="352" id="32574" videoCodec="mpeg4" videoFrameRate="24p" videoResolution="sd" width="624">
<Part container="avi" duration="2592548" file="S:\Videos\TV Shows\24\Season 07\24 - 7x04 - Day 7 1100 A.M. - 1200 P.M.avi" id="32651" key="/library/parts/32651/file.avi" size="366778368">
<Stream bitDepth="8" bitrate="987" chromaSubsampling="4:2:0" codec="mpeg4" codecID="XVID" colorSpace="yuv" duration="2592548" frameRate="23.976" gmc="0" height="352" id="88935" index="0" level="5" profile="asp" qpel="0" scanType="progressive" streamType="1" title="" width="624" />
<Stream bitrate="128" bitrateMode="vbr" channels="2" codec="mp3" codecID="55" duration="2592504" id="88936" index="1" samplingRate="48000" selected="1" streamType="2" title="" />
<Writer count="19" id="22117" tag="David Fury" />
<Writer count="22" id="22153" tag="Alex Gansa" />
<Director count="47" id="22090" tag="Brad Turner" />
<User id="1" thumb="http://www.gravatar.com/avatar/eeb6c8eefb714b4f903161fc704f5b61?d=404" title="chaoticmaster" />
<Player machineIdentifier="8bfa9c3c-40b1-e9d6-9619-b380c351d54f" platform="Android" product="Plex for Android" state="paused" title="My Nexus 5" />
<TranscodeSession key="8bfa9c3c-40b1-e9d6-9619-b380c351d54f" throttled="1" progress="79.900001525878906" speed="0" duration="2592000" videoDecision="transcode" audioDecision="transcode" protocol="dash" container="mp4" videoCodec="h264" audioCodec="aac" audioChannels="2" width="419" height="236" />
<Video addedAt="1377740339" art="/library/metadata/30/art/1377740577" duration="5020480" guid="com.plexapp.agents.imdb://tt2400312?lang=en" key="/library/metadata/30" lastViewedAt="1413838376" librarySectionID="1" ratingKey="30" sessionKey="13" summary="" thumb="/library/metadata/30/thumb/1377740577" title="&quot;At the Movies&quot; Tootsie/The Verdict/Sophies Choice/Airplane II (TV ..." type="movie" updatedAt="1377740577" viewOffset="994964">
<Media aspectRatio="1.78" audioChannels="2" audioCodec="ac3" bitrate="7477" container="mkv" duration="5020480" height="720" id="30" videoCodec="h264" videoFrameRate="24p" videoResolution="720" width="1280">
<Part container="mkv" duration="5020480" file="S:\Videos\Movies\Airplane II (1982)\Airplane II (1982).mkv" id="32" key="/library/parts/32/file.mkv" size="4692465149">
<Stream bitDepth="8" bitrate="7090" cabac="1" chromaSubsampling="4:2:0" codec="h264" codecID="V_MPEG4/ISO/AVC" colorSpace="yuv" duration="5020479" frameRate="23.976" frameRateMode="cfr" hasScalingMatrix="0" height="720" id="102014" index="0" language="English" languageCode="eng" level="41" profile="high" refFrames="4" scanType="progressive" streamType="1" title="" width="1280" />
<Stream bitDepth="16" bitrate="384" bitrateMode="cbr" channels="2" codec="ac3" codecID="A_AC3" dialogNorm="-27" duration="5020480" id="102015" index="1" language="English" languageCode="eng" samplingRate="48000" selected="1" streamType="2" title="" />
<User id="1" thumb="http://www.gravatar.com/avatar/eeb6c8eefb714b4f903161fc704f5b61?d=404" title="johndoe" />
<Player machineIdentifier="v8d5xnt7w4620529" platform="Chrome" product="Plex Web" state="playing" title="Plex Web (Chrome)" />
<TranscodeSession key="ytzymbky87zf47vi" throttled="1" progress="71" speed="0" duration="1304000" videoDecision="copy" audioDecision="transcode" protocol="http" container="matroska" videoCodec="h264" audioCodec="aac" audioChannels="2" width="1280" height="720" />

Open in new window

Question by:chaoticmaster
  • 2
  • 2
LVL 27

Accepted Solution

wilcoxon earned 2000 total points
ID: 40395329
I don't quite follow what you're asking in the second part but this change should give the results you want in the first part of your question.  Rainmeter regex plugin doesn't seem to follow normal patterns - regex engines are almost always greedy so you're original regex should have given the results you want.
RegExp=(?siU)<Part container=.*\\([^\\]*)".*<User id="1".*title="(.*)"

Open in new window

LVL 85

Expert Comment

ID: 40395384
(?siU)<Part container=.*\\([^\\]*)".*<User id="1".*title="(.*)"

Author Comment

ID: 40395922

Using ozo correct REGEX below. I modified it slightly for my needs.

I will set a variable:
get=<Part container=.*\\([^\\]*)\.\w{3,4}".*<User id="1".*title="(.*)".*

When 1 User is connected:

When 2 Users are connected:

Part two of my question was asking if it is possible to have one REGEX that can capture all the data for indiscriminate of the number of users . The XML data will always be in the same predictable sequence.
LVL 27

Expert Comment

ID: 40396018
What do you mean using ozo's correct REGEX?  His regex is identical to the one I provided (just minus the Regexp=).

It probably is not possible unless what you have supports array repeated captures.  In perl, you should be able to do something like:
my @cap = m{(?:<Part container=.*\\([^\\]*)\.\w{3,4}".*<User id="1".*title="(.*)".*)+}si;

Open in new window

However, I don't think that will work for you (you have "perl" listed as a zone but the syntax of Rainmeter/webparser is definitely different.

Author Comment

ID: 40396025
I actually didnt notice that you posted code. I will award you the points since you posted first.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question