generated from obsproject/obs-plugintemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add support for parsing key-value pairs in URL source response (…
…#97)
- Loading branch information
Showing
9 changed files
with
119 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ | |
} | ||
}, | ||
"name": "obs-urlsource", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": "Roy Shilkrot", | ||
"website": "https://github.com/occ-ai/obs-urlsource", | ||
"email": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "errors.h" | ||
#include "request-data.h" | ||
|
||
#include <obs-module.h> | ||
|
||
#include <sstream> | ||
#include <string> | ||
|
||
struct request_data_handler_response parse_key_value(struct request_data_handler_response response, | ||
const url_source_request_data *request_data) | ||
{ | ||
|
||
UNUSED_PARAMETER(request_data); | ||
|
||
// Create a string stream from the body | ||
std::istringstream body_stream(response.body); | ||
std::string line; | ||
|
||
// Iterate through each line of the body | ||
while (std::getline(body_stream, line)) { | ||
// Skip empty lines | ||
if (line.empty()) | ||
continue; | ||
|
||
// Split the line by the delimiter | ||
// look for the first occurrence of the delimiter from the beginning of the line | ||
size_t delimiter_pos = line.find(request_data->kv_delimiter); | ||
if (delimiter_pos != std::string::npos) { | ||
std::string key = line.substr(0, delimiter_pos); | ||
std::string value = line.substr(delimiter_pos + 1); | ||
response.key_value_pairs[key] = value; | ||
response.body_parts_parsed.push_back(line); | ||
} | ||
} | ||
|
||
return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters