{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-val/pulls/comments/133945093","pull_request_review_id":57185076,"id":133945093,"diff_hunk":"@@ -143,6 +151,135 @@ def update_video_status(edx_video_id, status):\n     video.save()\n \n \n+def get_video_transcript(video_id, lang_code):\n+    \"\"\"\n+    Get a video's transcript\n+\n+    Arguments:\n+        video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.\n+        lang_code: it will the language code of the requested transcript.\n+    \"\"\"\n+    try:\n+        transcript = Transcript.objects.get(video_id=video_id, language=lang_code)\n+    except Transcript.DoesNotExist:\n+        transcript = None\n+\n+    return transcript\n+\n+\n+def get_video_transcripts(video_id):\n+    \"\"\"\n+    Get a video's transcripts\n+\n+    Arguments:\n+        video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.\n+    \"\"\"\n+    transcripts_set = Transcript.objects.filter(video_id=video_id)\n+\n+    transcripts = []\n+    if transcripts_set.exists():\n+        transcripts = TranscriptSerializer(transcripts_set, many=True).data\n+\n+    return transcripts\n+\n+\n+def create_video_transcript(video_id, language, transcript_url, transcript_format, provider=TranscriptProvider.CUSTOM):\n+    \"\"\"\n+    Creates a transcript record for a video.\n+\n+    Arguments:\n+        video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.\n+        language: language code of a video transcript\n+        transcript_url: url of a video transcript\n+        transcript_format: format of the transcript\n+        provider: transcript provider\n+\n+    Raises:\n+        IntegrityError: raises IntegrityError if there is an existing transcript with same video_id and lang_code.\n+    \"\"\"\n+    transcript = Transcript.objects.create(\n+        video_id=video_id,\n+        language=language,\n+        transcript_url=transcript_url,\n+        fmt=transcript_format,\n+        provider=provider,\n+    )\n+\n+    return TranscriptSerializer(transcript).data\n+\n+\n+def update_video_transcript(video_id, language, transcript_url, transcript_format, provider=TranscriptProvider.CUSTOM):\n+    \"\"\"\n+    Update a transcript for a video\n+\n+    Arguments:\n+        video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.\n+        language: language code of a video transcript\n+        transcript_url: url of a video transcript\n+        transcript_format: format of the transcript\n+        provider: transcript provider\n+\n+    Raises:\n+        DoesNotExist: raises DoesNotExist if there is not any transcript for the given video_id and lang_code.\n+    \"\"\"\n+    transcript = Transcript.objects.get(video_id=video_id, language=language)\n+    transcript.language = language\n+    transcript.transcript_url = transcript_url\n+    transcript.fmt = transcript_format\n+    transcript.provider = provider\n+    transcript.save()\n+\n+    return TranscriptSerializer(transcript).data\n+\n+\n+def get_3rd_party_transcription_plans():\n+    \"\"\"\n+    Retrieves 3rd party transcription plans.\n+    \"\"\"\n+    return THIRD_PARTY_TRANSCRIPTION_PLANS\n+\n+\n+def get_transcript_preferences(course_id):\n+    \"\"\"\n+    Retrieves course wide transcript preferences\n+\n+    Arguments:\n+        course_id (CourseKey): a course key\n+    \"\"\"\n+    transcript_preference = None\n+    transcript_preference_set = TranscriptPreference.objects.filter(course_id=course_id)\n+    if transcript_preference_set.exists():\n+        transcript_preference = TranscriptPreferenceSerializer(transcript_preference_set.first()).data\n+\n+    return transcript_preference\n+\n+\n+def create_or_update_transcript_preferences(course_id, provider, **kwargs):\n+    \"\"\"\n+    Creates or updates course-wide transcript preferences\n+\n+    Arguments:\n+        course_id(CourseKey): a course key\n+        provider(str): transcript provider 3play/cielo24\n+\n+    Keyword Arguments:\n+        kwargs(dict): keyword arguments\n+    \"\"\"\n+    try:\n+        transcript_preference = TranscriptPreference.objects.get(course_id=course_id)","path":"edxval/api.py","position":150,"original_position":150,"commit_id":"1674ff42adcce7168f63acc16a44d2ef7f0e986f","original_commit_id":"1674ff42adcce7168f63acc16a44d2ef7f0e986f","user":{"login":"muzaffaryousaf","id":2994509,"avatar_url":"https://avatars3.githubusercontent.com/u/2994509?v=4","gravatar_id":"","url":"https://api.github.com/users/muzaffaryousaf","html_url":"https://github.com/muzaffaryousaf","followers_url":"https://api.github.com/users/muzaffaryousaf/followers","following_url":"https://api.github.com/users/muzaffaryousaf/following{/other_user}","gists_url":"https://api.github.com/users/muzaffaryousaf/gists{/gist_id}","starred_url":"https://api.github.com/users/muzaffaryousaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muzaffaryousaf/subscriptions","organizations_url":"https://api.github.com/users/muzaffaryousaf/orgs","repos_url":"https://api.github.com/users/muzaffaryousaf/repos","events_url":"https://api.github.com/users/muzaffaryousaf/events{/privacy}","received_events_url":"https://api.github.com/users/muzaffaryousaf/received_events","type":"User","site_admin":false},"body":"let's use get_or_create.","created_at":"2017-08-18T12:19:08Z","updated_at":"2017-08-18T12:19:09Z","html_url":"https://github.com/edx/edx-val/pull/89#discussion_r133945093","pull_request_url":"https://api.github.com/repos/edx/edx-val/pulls/89","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-val/pulls/comments/133945093"},"html":{"href":"https://github.com/edx/edx-val/pull/89#discussion_r133945093"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-val/pulls/89"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-val/pulls/89","id":133968692,"html_url":"https://github.com/edx/edx-val/pull/89","diff_url":"https://github.com/edx/edx-val/pull/89.diff","patch_url":"https://github.com/edx/edx-val/pull/89.patch","issue_url":"https://api.github.com/repos/edx/edx-val/issues/89","number":89,"state":"open","locked":false,"title":"Add course-wide Transcript Preference","user":{"login":"Qubad786","id":7848408,"avatar_url":"https://avatars3.githubusercontent.com/u/7848408?v=4","gravatar_id":"","url":"https://api.github.com/users/Qubad786","html_url":"https://github.com/Qubad786","followers_url":"https://api.github.com/users/Qubad786/followers","following_url":"https://api.github.com/users/Qubad786/following{/other_user}","gists_url":"https://api.github.com/users/Qubad786/gists{/gist_id}","starred_url":"https://api.github.com/users/Qubad786/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qubad786/subscriptions","organizations_url":"https://api.github.com/users/Qubad786/orgs","repos_url":"https://api.github.com/users/Qubad786/repos","events_url":"https://api.github.com/users/Qubad786/events{/privacy}","received_events_url":"https://api.github.com/users/Qubad786/received_events","type":"User","site_admin":false},"body":"1. Add course-wide Transcript Preference\r\n2. Prepare 3rd party transcription plans\r\n3. Api methods to use transcript prefs/plans in edx-platform\r\n4. Add an endpoint to update video status (for VEDA)\r\n5. Refactor ListField to support `max_items`","created_at":"2017-08-03T15:06:21Z","updated_at":"2017-08-18T12:19:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5be0c1904da6843d32adcacd9c670657fb2b29d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-val/pulls/89/commits","review_comments_url":"https://api.github.com/repos/edx/edx-val/pulls/89/comments","review_comment_url":"https://api.github.com/repos/edx/edx-val/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-val/issues/89/comments","statuses_url":"https://api.github.com/repos/edx/edx-val/statuses/1674ff42adcce7168f63acc16a44d2ef7f0e986f","head":{"label":"edx:mrehan/course-wide-transcript-preferences","ref":"mrehan/course-wide-transcript-preferences","sha":"1674ff42adcce7168f63acc16a44d2ef7f0e986f","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":21628067,"name":"edx-val","full_name":"edx/edx-val","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-val","description":null,"fork":false,"url":"https://api.github.com/repos/edx/edx-val","forks_url":"https://api.github.com/repos/edx/edx-val/forks","keys_url":"https://api.github.com/repos/edx/edx-val/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-val/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-val/teams","hooks_url":"https://api.github.com/repos/edx/edx-val/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-val/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-val/events","assignees_url":"https://api.github.com/repos/edx/edx-val/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-val/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-val/tags","blobs_url":"https://api.github.com/repos/edx/edx-val/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-val/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-val/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-val/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-val/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-val/languages","stargazers_url":"https://api.github.com/repos/edx/edx-val/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-val/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-val/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-val/subscription","commits_url":"https://api.github.com/repos/edx/edx-val/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-val/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-val/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-val/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-val/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-val/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-val/merges","archive_url":"https://api.github.com/repos/edx/edx-val/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-val/downloads","issues_url":"https://api.github.com/repos/edx/edx-val/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-val/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-val/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-val/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-val/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-val/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-val/deployments","created_at":"2014-07-08T20:11:27Z","updated_at":"2016-11-09T19:39:33Z","pushed_at":"2017-08-18T06:59:02Z","git_url":"git://github.com/edx/edx-val.git","ssh_url":"git@github.com:edx/edx-val.git","clone_url":"https://github.com/edx/edx-val.git","svn_url":"https://github.com/edx/edx-val","homepage":null,"size":693,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":8,"forks":12,"open_issues":8,"watchers":2,"default_branch":"master"}},"base":{"label":"edx:mrehan/val-transcripts-backend-api","ref":"mrehan/val-transcripts-backend-api","sha":"d9b039cc1a08b6c7eaf2d170391fab581e5136ea","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":21628067,"name":"edx-val","full_name":"edx/edx-val","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-val","description":null,"fork":false,"url":"https://api.github.com/repos/edx/edx-val","forks_url":"https://api.github.com/repos/edx/edx-val/forks","keys_url":"https://api.github.com/repos/edx/edx-val/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-val/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-val/teams","hooks_url":"https://api.github.com/repos/edx/edx-val/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-val/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-val/events","assignees_url":"https://api.github.com/repos/edx/edx-val/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-val/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-val/tags","blobs_url":"https://api.github.com/repos/edx/edx-val/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-val/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-val/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-val/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-val/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-val/languages","stargazers_url":"https://api.github.com/repos/edx/edx-val/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-val/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-val/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-val/subscription","commits_url":"https://api.github.com/repos/edx/edx-val/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-val/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-val/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-val/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-val/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-val/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-val/merges","archive_url":"https://api.github.com/repos/edx/edx-val/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-val/downloads","issues_url":"https://api.github.com/repos/edx/edx-val/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-val/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-val/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-val/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-val/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-val/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-val/deployments","created_at":"2014-07-08T20:11:27Z","updated_at":"2016-11-09T19:39:33Z","pushed_at":"2017-08-18T06:59:02Z","git_url":"git://github.com/edx/edx-val.git","ssh_url":"git@github.com:edx/edx-val.git","clone_url":"https://github.com/edx/edx-val.git","svn_url":"https://github.com/edx/edx-val","homepage":null,"size":693,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":8,"forks":12,"open_issues":8,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-val/pulls/89"},"html":{"href":"https://github.com/edx/edx-val/pull/89"},"issue":{"href":"https://api.github.com/repos/edx/edx-val/issues/89"},"comments":{"href":"https://api.github.com/repos/edx/edx-val/issues/89/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-val/pulls/89/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-val/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-val/pulls/89/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-val/statuses/1674ff42adcce7168f63acc16a44d2ef7f0e986f"}}}}
{"actor":{"display_login":"muzaffaryousaf"}}