How to use the subtitle/lib/parse function in subtitle

To help you get started, we’ve selected a few subtitle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github France-ioi / codecast / frontend / subtitles / loading.js View on Github external
function* subtitlesLoadFromTextSaga ({payload: {key, text}}) {
  const scope = yield select(state => state.get('scope'));
  yield put({type: scope.subtitlesLoadStarted, payload: {key}});
  let items;
  try {
    items = srtParse(text);
  } catch (ex) {
    yield put({type: scope.subtitlesLoadFailed, payload: {key, error: ex}});
    return;
  }
  yield put({type: scope.subtitlesLoadSucceeded, payload: {key, text, items}});
}
github France-ioi / codecast / frontend / subtitles / loading.js View on Github external
function* subtitlesLoadFromUrlSaga ({payload: {key, url}}) {
  const scope = yield select(state => state.get('scope'));
  yield put({type: scope.subtitlesLoadStarted, payload: {key}});
  try {
    const text = yield call(getSubtitles, url);
    const items = srtParse(text);
    yield put({type: scope.subtitlesLoadSucceeded, payload: {key, text, items}});
  } catch (ex) {
    yield put({type: scope.subtitlesLoadFailed, payload: {key, error: ex}});
  }
}
github France-ioi / codecast / frontend / subtitles / loading.js View on Github external
function* subtitlesLoadFromFileSaga ({payload: {key, file}}) {
  const scope = yield select(state => state.get('scope'));
  try {
    const text = yield call(readFileAsText, file);
    const items = srtParse(text);
    yield put({type: scope.subtitlesLoadSucceeded, payload: {key, text, items}});
  } catch (ex) {
    yield put({type: scope.subtitlesLoadFailed, payload: {key, error: ex}});
  }
}

subtitle

Stream-based library for parsing and manipulating subtitles

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis